Multiple commands on one line in a batch file

Advertisement

Mark_D
Joined:
Posts:
4
Location:
London, England

Multiple commands on one line in a batch file

Hi all

I want to make it easier for some of mu colleagues to write a site specific batch file to retrieve some files. We have the ability to export some details in to excel and I can ther3efore get excel to insert the relevant info in to a long text string.

For this to work I need ALL of the commands in the following code to be on one line.
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /command ^
    "open ftp://anonymous:anonymous%%40example.com@10.203.63.14/" ^
    "cd /\STRATEGY\" ^
    "lcd ""C:\Users\Mark Dullingham\Documents\Backup Test""" ^
    "get L030N014.IQ3" ^
    "exit"
I think it has something to do with the ^ symbol but I'm not sure how to remove this or does it need to be replaced by another symbol.

Any help much appreciated.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Multiple commands on one line in a batch file

The command line (for any application) is actually one-line only always.

Only in Windows batch files you can visually break that one line into multiple lines by delimiting the "new line" with the ^.

The ^ is not WinSCP syntax, it's a batch file syntax. WinSCP never sees the ^.

So your batch file actually executes this command-line:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /command "open ftp://anonymous:anonymous%%40example.com@10.203.63.14/"    "cd /\STRATEGY\" "lcd ""C:\Users\Mark Dullingham\Documents\Backup Test""" "get L030N014.IQ3" "exit"
And that answers your question.

Reply with quote

Advertisement

You can post new topics in this forum