PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How to continuously upload files with WinSCP

 August 01, 2022     batch-file, ftp, winscp     No comments   

Issue

I want my WinSCP script to loop.

Starting script (.bat file)

winscp.com /script=SyncToRemoteScript.txt
pause

My script (.txt file)

open ftp://usernam:password@myhost/ -hostkey="ssh-ed25XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX="
put D:\folder /home/myuser/public_html/wp-content/themes/newtheme
exit

I tried GOTO method like this – not working.

:start
open ftp://usernam:password@myhost/ -hostkey="ssh-ed25XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX="
put D:\folder /home/myuser/public_html/wp-content/themes/newtheme
goto start

Tried while also, but CMD tells me "Unknown command 'While'". I googled that problem can solved by saving the file ASCII, but it's not working either.


Solution

There's no goto command in WinSCP.

But there's goto command in Windows batch file, so you can do:

:start
winscp.com /script=SyncToRemoteScript.txt
goto start

For a bit more complex code, see WinSCP Retrying Script example.


Though as you seem to try to continuously update a remote directory, consider using:

  • synchronize remote command to update only modified files.
  • keepuptodate command to continuously update modified files (and you won't need any loop).


Answered By - Martin Prikryl
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing