Re: Execute WinSCP from a batch file
can u share the code
What code? There are zillions of examples on this site:
https://winscp.net/eng/docs/library#example
can u share the code
Thanks Martin,i checked it.
I have used C# with WinSCP dll and accomplished the task.
I realized it's much easier and faster that way in terms of exception handling :D
Thanks!
What did you try to get the logs?
Did you ever resolve this issue? I am experiencing the same issue - no log files to give me a hint at the problem.
I am trying to run winscp from bat file and with xp_cmdshell in sql server. However when I run it keeps running forever. I have put exit in bat file. Anybody aware of this issue?
Also is there any way to capture winscp dir results in sql server table or like normal result set instead of XML.
-passphrase
switch:
open xxxxxx -passphrase=mypassphrase
open xxxxxx (site already stored with host name, port and username)
passphrase
get *.txt to c:\*.txt
Close
exit
@echo off
winscp.com /script=getfile.txt
I don't understand. On the following page it shows this example batch file, which combines WinSCP and Windows commands:
https://winscp.net/eng/docs/guide_automation
example.txt
.
winscp.com /script=example.txt
if %ERRORLEVEL% neq 0 goto error
echo Success
sendmail.exe -t < success_mail.txt
exit 0
:error
echo Error!
sendmail.exe -t < error_mail.txt
exit 1
I did the following batch file to send file to sftp server, but the put command (or any commands) after sftp session opeded didn't work:
cd C:\Program Files\prog1\output1
WinSCP.exe username@x.x.x.x/example/test
put %file%
close
exit
I am trying to run winscp from bat file and with xp_cmdshell in sql server. However when I run it keeps running forever. I have put exit in bat file. Anybody aware of this issue?
/log=path_to_log_file
command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
C:\MYFILE.BAT
echo " OPENING THE SESSION "
winscp.com /console /command:"open xyz:abc@ipaddress"
echo "CONNECTED TO THE VM "
REM delete old files
rm file1.tar
C:\>MYFILE.BAT
, I am able to connect to unix vm, however it goes into shell mode and second command (deleting file1.tar
won't get executed). do we need to give any other parameter?
winscp.com /script:filename.bat
) but in that case i can't check errors with if/ else conditions in batch file since winscp doesn't recognise the if/else.