Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Roman Belousov wrote:

For some reason the instructions at the bottom of the file generated by WinSCP don't work

Can you please elaborate on the problem?
Roman Belousov

I was able to figure WinSCP automation out. For your info, here's what works:

  1. Get WinSCP to generate the script for you. You'll need the line at the top as that contains the SSL certificate as well as a properly-formatted user and password authentication.
  2. For some reason the instructions at the bottom of the file generated by WinSCP don't work, so instead do this;
  3. Create a batch file, in my case I saved in c:\. The file has the following 3 lines:
    cd Program Files (x86)\WinSCP
    type get_script.txt | winscp

  4. create get_script.txt in Program Files (x86)\WinSCP (the standard directory it installs in), it contains the following 5 lines:
    open sftp://<the rest of that first line from step 1>
    cd /out
    lcd C:\XML
    get -delete *.xml

  5. your files will appear in C:\XML.

You have to use the type command in the batch file, simply listing the commands stops working as soon as you're in WinSCP's prompt (it has its own prompt).

I hope this comes in handy later, thank you and good luck.

My regards,
Roman Belousov

Re: Trying to automate get -delete

It does not look like you have a problem with get -delete but rather with an authentication.

Can you authenticate in WinSCP GUI?

If you can, then have WinSCP GUI generate a code template for you:
Roman Belousov

Trying to automate get -delete

Hey guys, so I've created bunn_get.txt in C:\Program Files (x86)\WinSCP and it goes like this:
open sftp://<key> -hostkey="ssh-rsa 2048 <another key>="
cd /out
lcd C:\GD\Emails\Bunnings
get -delete *.xml
#also tried get -delete *.xml C:\GD\Emails\Bunnings
# Execute the script using a command like:
# "C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\GD\Emails\Bunnings\archive\WinSCP.log" /ini=nul /script="C:\bunn_get.txt"

And I've created bunn_edi.bat in c:\
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\GD\Emails\Bunnings\archive\WinSCP.log" /ini=nul /script="C:\bunnings_get.txt

Nothing's happening. When I try to open the terminal window in WinSCP, I get the error:
Authentication log (see session log for details):

Using username "<username>".

Authentication failed.

Any ideas?

My Regards
Candoo Business Systems