![]() Based on past experience, I've found that using both of these switches helps to mitigate problems - especially when overwriting files on remote SFTP servers. ![]() WinSCP's put command documentation tells us that nopermissions keeps default file permissions, and nopreservetime instructs the remote server to replace timestamp information. You may be curious about the nopermissions and nopreservetime switches. I then change the local directory to C:\temp, and instruct the SFTP client to copy a subfolder named "asubfolder", lastly, I instruct the client to copy a single document named atestdoc.txt to the remote server before exit: option echo off option batch on option confirm off open #Change LOCAL directory lcd "C:\temp\" #copy an entire folder put -nopermissions -nopreservetime "asubfolder" #copy an individual file put -nopermissions -nopreservetime "atestdoc.txt" atestdoc.txt exit ![]() In this example, I am opening a connection to an SFTP server (192.168.1.17) on my local network, specifying username (glasskeys) with password (somepassword). Notice too, the script file is named uploadscript.txt, specified by the /script parameter.įinally, we examine the script file itself. off REM Next line NOT needed if WinSCP folder was added to PATH REM CD "C:\Program Files (x86)\WinSCP" /script=C:\temp\uploadscript.txt Notice the commented lines in the file, these lines are not needed if the option to add the WinSCP's folder to %PATH% was selected during installation. For example, this is a listing of a batch file named deploy.bat - used to start the SFTP client with script file. I kick off SFTP scripts from the command line using a traditional batch file. Doing this allows you to easily add the remote server's host key to WinSCP's key cache. Also, if possible, connect to the remote SFTP server first with the GUI application before connecting via the command line.
0 Comments
Leave a Reply. |