Topic "Bat/Script file not working"

Author Message
Cwaldschmit

Guest


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?
log 2.log (6.45 KB) [Download]

Description: Log that's not working

log 1.log (12.63 KB) [Download]

Description: Log that's working

Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Your code is just wrong.

This is the correct syntax:

Code:
"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"
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
I've tried out your code in CMD. And it does nothing except starting up winscp in cmd. All other commands are unknown.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
The ^'s are a batch file syntax. It does not work in the cmd.exe console. If you want to test it, add the command to a batch file and execute that.

In the cmd.exe console, you have to remove the ^ and put everything on a single line.
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
I mean that you copy and paste the code from my post to a .bat file, exactly.

There's no upload.txt involved.
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
It only starts winscp in command promt but doesn't do anything else at all.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
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.
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
This is the result
cmd2.PNG (13.07 KB)

Description: (none)

cmd2.PNG

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
You have to use the ^'s in the batch file.
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
Fort some reason its not opening the connection. The password does exist a & could that be the problem?
cmd3.png (32.13 KB) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Your batch file is still not, what I've shown you to use.

Please attach your batch file.
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
I can send the bat file but I can't give you the password of the server. Is that a problem?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Remove all information you do not want to share.
_________________
Martin Prikryl
Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
Here is the .BAT file
upload.bat (260 Bytes) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
You have this:

Code:
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:

Code:
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.

I'm attaching a fixed batch file.
upload.bat (331 Bytes) [Download]

Description: (none)

Cwaldschmit
[View user's profile]

Joined: 2016-10-05
Posts: 8
Location: The Netherlands
Well as a .BAT file your code isn't working. After starting up winscp.com it does nothing. When I type exit and enter the bat files continues.
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
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.
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