Best procedure to run a command line script.

Advertisement

tommytx
Guest

Best procedure to run a command line script.

Please help me out here as I am completely lost. I want to run a command line script and not sure where on the hard drive to put the script.. I made a batch file and an example script and tried that but no workee.. Do I have to find the same directory that winscp.exe is located to place my bat file and example file..
I looked for the c:/Program Files/WinScp/winscp.exe but could not find anything like that on my hard drive.
I do have winscp installed and can use the interface easily and it works well.


Code inside example.txt
winscp.com /ini=nul /command ^
    "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" ^
    "get examplefile.txt d:\" ^
    "exit"

Code inside my batch file.
winscp.com /ini=nul /script=example.txt

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Best procedure to run a command line script.

This is not a WinSCP script, its a complete batch file:
winscp.com /ini=nul /command ^
    "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" ^
    "get examplefile.txt d:\" ^
    "exit"

So store the above lines to the batch file. You do not need any example.txt.

Reply with quote

Guest

Thanks for the extra info but they question was how and where do I run it. must it be in the Winscp directory with the winscp.exe or the .com.. I assume to run a script i would use the .com..

Reply with quote

Guest

Like for example i get into this directory:

C:\Program Files (x86) \WinScp>

and try something like this.. "Open sftp://user:pass@vahud.com"
and nothing happens.. about the only thing I can get to run is simple old dos commands like cd and dir..

Reply with quote

martin
Site Admin
martin avatar

Again, store the lines from my post to a batch file (e.g. upload.bat). And run the batch file.

Ideally use absolute paths in the batch file (both to the winscp.com and the source local file). Then it would not matter, what directory you store the batch file to.

Reply with quote

Advertisement

You can post new topics in this forum