1

I am currently writing a script that calls WinSCP, connects an SFTP session, transfers a group of files from a local server to a remote server, closes the connection, then moves the local file to an archive. An alternate acceptable solution would be to copy the file to archive and then delete it from the source directory.

The problem I am having is that I can get WinSCP to open, connect and transfer the files, but after that the commands are ignored and I am unable to automate the connection close, file move or copy and the deletion and closing of command prompt. What is the best way to do this?

My FTP.bat file that connects the session and calls the script -

"C:\Program Files\WinSCP\WinSCP.exe" /console /command "lcd d:\bofa_ftp\out" /script=script.txt [email protected]

My script file that puts the file and closes the connection -

option batch abort
option confirm off
option exclude script.txt
put *.txt
close

When I add any commands to either the bat or the script they are ignored.

1
  • Take a look at the console/scripting mode section of the docs... You can pass a separate batch file to the .exe to execute the commands you need once connected apparently. Commented Mar 13, 2012 at 22:04

2 Answers 2

2

Commands after close are definitely not ignored. Your problem might be that you are trying to put Windows commands to WinSCP script. Note that there are no commands in WinSCP to move local files.

Sign up to request clarification or add additional context in comments.

Comments

-1

Instead of trying using Winscp3, try with plink.exe.

Plink is the best option to transfer files from winscp3 to your local.By using scp command we can transfer file from winscp to local as well as one folder in to another folder in winscp.

scp [email protected]:/data/tmp/samplscp.txt [email protected]:/data/tmp/dir/tech

Please refer to: http://99students.com/move-files-in-unix/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.