Post a reply

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

George M

Get Command Issue

Hi,
I am using FTPS command which we are able to connect FTP successfully using batch script, unfortunately it is not proceeding further, it says active session after connecting to the FTP and going to the screen as below winscp> like this but when we type the get command from the existing session, it works properly but not through batch script and no issues with the command.

Is there any restriction possibility.

Thanks
Inkster jim

Hi Prikryl,

Maybe I should simplify things.

I want to create a simple script to put several files everyday to a remote server. I have a session that I can do that manually in the GUI. The session is called "Counter Reports"

Can I create a batch file (call it put.txt) that looks like this...
option batch on
option confirm off
open Counter Reports
mput D:\folder1\folder2\*.CSV [/b]<-(this is my machine)  (don't know what the remote recieving machine path should look like...
exit

And then to run it, what would be the command I should use and from where (meaning what folder) should I run it from? I have included c:\program files\winscp in the path.

Thanks.
Inkster jim

Creating a new Session

Martin,

Can you help me with these:

When I first open WinSCP I get the WinSCP login
Session
Stored sessions
Environment
Directories

SSH
Preferences

When I hit new the box opens up with the Host Name, Port Number, Password etc....
Supposedly the Password text box is supposed to be prepopulated with a password and what you see is a bunch of ************ inside. This is what another person who has used it gets. For some reason I do not. How do I get a password entered? Thanks
Inkster jim

Re: the script works when run manually, but cannot through batch

Hi @martin,

I am brand new to WinSCP. You seem to know your stuff on WinSCP. I'm not sure what you call the scripting language here in WinSCP, that is, if it is different that Windows scripting.

I need to send multiple files to a remote site in a secure FTP. Here is how I did it before it had to become SFTP enabled. Here are what my current scripts look like:

RUN.BAT
@echo off 
REM ------------------------------------------
REM This batch file will run an ftp upload
REM then delete files on the current computer.
REM ------------------------------------------
REM Start the upload
echo ----------------------------------
echo Start uploading at %TIME%
echo ----------------------------------
ftp -s:putfile.txt XXX.XX.XXX.XXX //runs the text file below
REM Done uploading, now delete the files on the local machine
echo ----------------------------------
echo Deleting local files
echo ----------------------------------
del D:\FTP_FOLDER\III to DOR\hello*.txt // deletes the files on my side after the ftp
REM copy over the files on the root to replace the one's just deleted
echo ----------------------------------
copy D:\helloworld*.txt
echo ----------------------------------
echo Upload complete at %TIME%.
echo ----------------------------------

Kicks off this file:
PUTFILE.TXT
jdoe // user name 

jdoe // password
prompt
cd uploads
mput helloworld*.txt /files to be trasferred
bye

My question is – How can I modify this so it will run as a batch file using WinSCP?

Thanks!
Jim
martin

Re: the script works when run manually, but cannot through batch

OK, only now I have noticed your script file. You are mixing Windows batch file commands and WinSCP script commands in a single file. You cannot do that.
See https://winscp.net/eng/docs/faq_batch_file#cmd
kathryn

Re: the script works when run manually, but cannot through batch

I have changed the batch file to the following, but it doesn't seem to work...
"c:\Program Files\WinSCP3\WinSCP.exe"
/script="C:\Documents and Settings\kathrynt\Desktop\script.txt"

I wonder is it because I want to use winscp.com in the script, but in the batch file I ran winscp.exe? I changed the above from .exe to .com, not working either...
kathryn

Re: the script works when run manually, but cannot through batch

Let me try that. Thank you so much;)
martin

Re: the script works when run manually, but cannot through batch

You have to enclose the path to the script to double-quotes as it contains spaces (the same way you have done with path to winscp.exe).
kathryn

The script works when run manually, but cannot through batch

I am new to WinSCP.
I want to synchronize the remote with the local on daily basis.
Manually, the following script works (TNDOSSession is a stored session):
cd c:\program files\winscp

winscp.com TNDOSSession
synchronize c:\TNDOS\Files /internet/safety/vendors/TNOmnigov
close
exit

I added the options at the top as suggested, then saved the above as a script.txt.

Then I constructed the following batch file as instructed, but it doesn't work.
"c:\Program Files\WinSCP3\WinSCP.exe"
/script=C:\Documents and Settings\kathrynt\Desktop\script.txt

I tried to change the above from .exe to .com, doesn't work either.

Then, I made the script.txt to script.bat, and it worked until opened the stored session, but it doesn't synchronize and exit.

I went through the FAQ, seems others having this problem too, but I don't understand the explanation there (T-T)

Please help.
Thanks so much!
Kathryn