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:
39,423
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:
39,423
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:
39,423
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 https://winscp.net/eng/docs/faq_batch_file

I'm attaching a fixed batch file.

Reply with quote

Advertisement

Guest

Make sure you remove the extra spaces beyond the ^.

I copied his script and pasted it into notepad and each line has an extra space at the end so if you copied his script, saved it without changing anything and tried running it, I'm sure it would fail.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
39,423
Location:
Prague, Czechia

Anonymous wrote:

Make sure you remove the extra spaces beyond the ^.

I copied his script and pasted it into notepad and each line has an extra space at the end so if you copied his script, saved it without changing anything and tried running it, I'm sure it would fail.
That's correct. There are actually no spaces after the ^'s in my post. But unfortunately, it is rendered with spaces.

Reply with quote

Advertisement

You can post new topics in this forum