Bat/Script file not working

Advertisement

Cwaldschmit
Guest

Bat/Script file not working

Hello,

I've got the following problem. I can't get the following code to work automatic trough a .BAT file or with a script:
batch continue
option confirm on
"C:\Program Files\WinSCP\WinSCP.com" ^
  /log="C:\Users\PC0102\Desktop\cz2\WinSCP.log" /ini=nul /loglevel=2*^
  /command ^
    "open ftps://PRC:*@datatransfer.cz.nl
  CD Incassopartner2CZ
  CD Input
  put C:\Users\PC0102\Desktop\cz2\Bestanden\ /prc/Incassopartner2CZ/Input
When I put this code in my cmd it's working perfect (See log 1). When I try the same code in a .BAT file or with a .BAT file who calls on a script its only connecting to the server and isn't doing anything anymore (see log 2). Is there anyone who could help me with this problem?
Description: Log that's not working
Description: Log that's working

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,552
Location:
Prague, Czechia

Re: Bat/Script file not working

Your code is just wrong.

This is the correct syntax:
"C:\Program Files\WinSCP\WinSCP.com" ^
  /log="C:\Users\PC0102\Desktop\cz2\WinSCP.log" /ini=nul /loglevel=2* ^
  /command ^
    "option batch continue" ^
    "option confirm on" ^
    "open ftps://PRC:*@datatransfer.cz.nl" ^
    "CD Incassopartner2CZ" ^
    "CD Input" ^
    "put C:\Users\PC0102\Desktop\cz2\Bestanden\* /prc/Incassopartner2CZ/Input/" ^
    "exit"

Reply with quote

Cwaldschmit
Joined:
Posts:
8
Location:
The Netherlands

How do you mean exactly?
I've been trying out some stuff atm
I got a .bat file now that activates the .txt script.
But for some reason it says
Host "upload.txt" does not exist

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar

I mean that you copy and paste the code from my post to a .bat file, exactly.

There's no upload.txt involved.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,552
Location:
Prague, Czechia

OK, assuming your batch file is called upload.bat:
Open console (cmd.exe) and type:
type upload.bat
upload.bat
And post a screenshot of the result.

Reply with quote

Advertisement

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,552
Location:
Prague, Czechia

You have this:
C:\Users\PC0102\Desktop\cz2\WinSCP\winscp.com ^
/command ^
option batch off ^
option confirm on ^ 
open ftps://*:*@datatransfer.cz.nl ^     
CD Incassopartner2CZ ^ 
CD Input ^ 
put C:\Users\PC0102\Desktop\cz2\Bestanden\ /prc/Incassopartner2CZ/Input ^

And I've asked you to do this:
C:\Users\PC0102\Desktop\cz2\WinSCP\winscp.com ^
    /command ^
        "option batch off" ^
        "option confirm on" ^
        "open ftps://*:*@datatransfer.cz.nl" ^
        "CD Incassopartner2CZ" ^
        "CD Input" ^
        "put C:\Users\PC0102\Desktop\cz2\Bestanden\ /prc/Incassopartner2CZ/Input" ^
        "exit"
You are missing the indentation (leading spaces), double-quotes around commands and the exit command.
And on many lines, you have spaces after the ^. That's not allowed. The ^ must be the very last character on the line.

See Why are some WinSCP scripting commands specified in a batch file not executed/failing?

I'm attaching a fixed batch file.

Reply with quote

Advertisement

George
Guest

WinSCP Command Through BatchScript

Hi,

Need your assistance, I am able to connect the FTP using batch script for the WinSCP but it is not able to do get the files but manually we are able to do it.
echo on
del ftpcmd.log
batch continue
option confirm on
winscp.com /log=ftpcmd.log /command ^
    "open ftps://XXXXXX:XXXXXXX" -hostkey="ssh-rsa 2048 xxxxxxxxxxx..." ^ 
"get /TEST_RPT/ c:\test" ^
"exit"
It is showing at below command
Active session: [1] FTP URL
winscp>

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,552
Location:
Prague, Czechia

Re: WinSCP Command Through BatchScript

@George: This is all discussed above already. There must be no space after ^ and the next line must be indented. Also your batch continue and option confirm on commands are misplaced and invalid. And your quotes are wrong.
echo on
del ftpcmd.log
winscp.com /log=ftpcmd.log /command ^
    "option batch continue" ^
    "option confirm on" ^
    "open ftps://XXXXXX:XXXXXXX -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...""" ^
    "get /TEST_RPT/ c:\test" ^
    "exit"
Again, see Why are some WinSCP scripting commands specified in a batch file not executed/failing? (linked two times already above).

Reply with quote

Advertisement

You can post new topics in this forum