Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
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)

Options

Topic review

martin

Re: Any way to show script progress in dos window, when runing a .bat that calls a script file?

thinclient wrote:

I would like to see the results of the script in dos prompt but when I launch the batch file from DOS prompt it connects, calls the script, which sftp's the file into the directory. It works, but all I see in the DOS prompt is this:
"C:\Program Files (x86)\WinSCP\WinSCP.exe"
/log="C:\Logs\WinSCP.log"
/ini=nul /command
/script="C:\Script.txt"

...

Use the winscp.com, not winscp.exe:
https://winscp.net/eng/docs/executables
thinclient

Any way to show script progress in dos window, when runing a .bat that calls a script file?

I would like to see the results of the script in dos prompt but when I launch the batch file from DOS prompt it connects, calls the script, which sftp's the file into the directory. It works, but all I see in the DOS prompt is this:
"C:\Program Files (x86)\WinSCP\WinSCP.exe"
/log="C:\Logs\WinSCP.log"
/ini=nul /command
/script="C:\Script.txt"

And I would like to see the script running e.g. if script has a command dir I'd see a directory listing output to DOS prompt.

Thanks,
thinclient
martin

Re: Need to build a batch file to send files sFTP via winscp

For automation please read FAQ.
Dan

THANKS!

That worked, thank you SO much!
Guest

Put the individual steps into your script file.

For example: my_script.txt contains the following
# start script code
open MyUserName:MyPassword@MySFTPserver.net
option transfer binary
get TestFile.txt c:\
close
# end script

put my_script.txt in the same folder as winscp.exe

You should now be able to use the script to ftp
promp> winscp.exe /console /script=my_script.txt

if this works okay then all your bat file needs to have in it is the above command.

my_ftp.bat contains
winscp.exe /console /script=my_script.txt


When you run my_ftp.bat all it does is executes the command with options you've included.

-jim
dharper3

Thanks!
I got some scripts running using command line and winscp.com
Question: What does the batch file look like?
C:\Program Files\WinSCP\winscp.com

open MyUserName:MyPassword@MySFTPserver.net
get TestFile.txt c:\
close
exit

will not work, but it will in command line.

I am so close, so tired, so frustrated.

thanks

dan
jc

winscp bat file

The script that you listed is to be interpreted by winscp. In the documentation

https://winscp.net/eng/docs/scripting

this script is named example.txt see the two examples at the bottom of the docs page to see the command line syntax for using the script.

Open a shell window, at the command prompt experiment with these commands and options and when you find the right command/syntax to accomplish the task from the command line, put that code into your bat file.

Good Luck,
-jc
Guest

Ok, let me ask it this way.
If I save the following file in a .bat file and run it, shouldn't it work?
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
open myuserName:MyPassword@myftpserver.net:22 (DO I need :22 here?)
# Change remote directory
cd /usr/home/ftpaccts/MyDirectory/
# Force binary mode transfer
option transfer binary
# Download file to the local directory
get TestFile.txt C:\Documents and Settings\Administrator\Desktop\DATA_IN
# Disconnect
close
exit

-OR- Asked another way, if I set up windows scheduled event to fire up WinSCP, WHERE do I add the code to run the get and put? I only have a place for putting comments in the scheduled task. I'm running Windows 2003 server.

Thank you for any clarity

Dan
Guest

Thanks, tried that one, no luck.
I was just wondering if anyone had a batch file they could cut and paste so I could take a look at the code.

thanks

Dan
martin

Re: Need to build a batch file to send files sFTP via winscp

You will find an example in documentation.
For scheduling, see FAQ.
DHarper2

Need to build a batch file to send files sFTP via winscp

<Moved from Documentation Forum...DUH!>

Hi-
I am a mac java guy transitioning to windows / .net.
I need to automate the sending of a file via winSCP. I have it set up on my windows 2003 server and can drag and drop via the GUI. However, I need to send a file on a weekly basis from sql2005. Can someone point me to a batch file 'how to' to walk me through building a .bat file? I am assuming I can then schedule the bat file to fire off at the desired time via scheduled events in windows. Bonus points for any scripts that can fire off a bat file from asp.net.

TIA

Dan