Topic "the script works when run manually, but cannot through batch"

Author Message
kathryn

Guest


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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
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).
_________________
Martin Prikryl
kathryn

Guest


Let me try that. Thank you so much;)
prikryl wrote:
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

Guest


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...
prikryl wrote:
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).
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
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.
Please read scripting guide carefully
http://winscp.net/eng/docs/guide_automation
_________________
Martin Prikryl
Inkster jim
[View user's profile]

Joined: 2011-05-23
Posts: 11
prikryl wrote:
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).


Hi prikryl,

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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Inkster jim wrote:
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: ...

See reply here
http://winscp.net/forum/viewtopic.php?t=9721
_________________
Martin Prikryl
Inkster jim
[View user's profile]

Joined: 2011-05-23
Posts: 11
[quote="Inkster Jim"]
Prikryl,

Can you help me with these:

1) 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
[View user's profile]

Joined: 2011-05-23
Posts: 11
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 <-(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
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License