Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using WINSCP from a .bat

Status
Not open for further replies.

Cretin

Technical User
Jan 2, 2003
194
US
Hey I need to transfer a file from a windows box to LINUX using WINSCP in a .bat. The issue is `if there is a problem when automating the script the job will hang. There is an option batch abort fommand but is not working.


C:
cd \Program Files\winSCP
option batch abortset user=user
Set passwd=password
set pathL="/u02/prn/oradata/utl/eligxfer"
set pathW= \\ntserver1.restat.net\outbound\test\eligdrop700

echo running FTP now

winscp.com /console %user%:%passwd%@testbox /command "put %pathW%\*.srpt %pathL%/*.rpt" exit

But when I try using that I get the following message

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\Dbaservice>E:

E:\>cd E:\Operations\RESTAT_SCRIPTS\ELIG_TBA_LOAD

E:\Operations\RESTAT_SCRIPTS\ELIG_TBA_LOAD>elig_ftptest.bat

E:\Operations\RESTAT_SCRIPTS\ELIG_TBA_LOAD>C:

C:\Documents and Settings\Dbaservice>cd \Program Files\WinSCP

C:\Program Files\WinSCP>set user=FDCOFTP

C:\Program Files\WinSCP>Set passwd=FDCOFTP99

C:\Program Files\WinSCP>set path=":/u02/ant/oradata/utl/eligreport"

C:\Program Files\WinSCP>set path1=E:\Operations\RESTAT_SCRIPTS\ELIG_TBA_LOAD

C:\Program Files\WinSCP>winscp.exe FDCOFTP:FDCOFTP99@qdbs1001 /command "put E
:\Operations\RESTAT_SCRIPTS\ELIG_TBA_LOAD\*.txt ":/u02/ant/oradata/utl/eligrepor
t"/*.txt" exit
C:\Program Files\WinSCP>ftp_elig_reports.bat
'ftp_elig_reports.bat' is not recognized as an internal or external command,
operable program or batch file.

E:\Operations\RESTAT_SCRIPTS\ELIG_TBA_LOAD>C:

C:\Program Files\WinSCP>cd \Program Files\WinSCP

C:\Program Files\WinSCP>option batch abort
'option' is not recognized as an internal or external command,
operable program or batch file.

I have tried many variations like "option batch abort" option "batch abort" /option batch abort etc, any ideas?








Cretin
 
First problem:

C:\Program Files\WinSCP>ftp_elig_reports.bat
[highlight #FCE94F]'ftp_elig_reports.bat' is not recognized as an internal or external command,
operable program or batch file.[/highlight]

Your batch file is calling another batch file, but it cannot find it... If you need this batch file to run, I would use the CALL command, and include the full path to where "ftp_elig_reports.bat" is found. For example
CALL C:\MyPath\ftp_elig_reports.bat

Regarding "option batch abort", that is not a batch file option, it's a WinSCP command. Google implies that this would be the correct syntax:
winscp /command "option batch abort"

Or, create a script file and run it from there.

Also, it seems like winscp.com would be the utility to use in this case, instead of winscp.exe (see below)... not sure though
 
C:\Program Files\WinSCP>ftp_elig_reports.bat
'ftp_elig_reports.bat' is not recognized as an internal or external command,
operable program or batch file.

If a directory/folder name has spaces in it the whole path MUST be enclosed in quote marks


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
You should check the WinSCP documentation a little more. There is an option to run a script file from it. Much easier than trying to put it all in a batch file. You can even log on once and save the credentials so it will use the same ones later.
For example:
winscp /HostName /script=MyScript.TXT

"HostName" is the name you give to the previously logged in session, with your username and password.
"MyScript.TXT" is the script file to run.

The script file MyScript.TXT can contain:
option batch on
option confirm off
put MyFile.txt /MyFile.txt
close
exit


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top