1.

Solve : Help with quoting syntax for .bat arguments?

Answer»

Hi,

I'm trying to use a batch script to rsh into a linux machine, but I'm having problems with MS-DOS trying to execute bits of my arguments.

I have a batch script which goes like this:

MYPROG.DAT
Code: [Select]@ECHO off
rsh somemachine -l someuser -n linuxcommand --parameter1=something --parameter2='"addurl %1"'
It seems to run OK with a DUMMY argument
Code: [Select]MYPROG http://dummy
linuxcommand: unknown host dummy
But if fails when it comes to the real thing
Code: [Select]MYPROG 'http://somewher.org/something.cgi?fred=x1|x2|x3'
'x2' is not recognised as an internal or external command, operable program or batch file
I've TRIED double-quote ("), single-quote ('), BACKSLASH (\), and various combinations of all three, but MS-DOS keeps on trying to execute x2 instead of passing it unparsed as an argument to my script.

Any ideas please?
Ken.You are trying to put the pipe (|) char in, it wont do it ... Im SURE theres a way to fix it, but Im not sure how;

Perhaps you could use a different char as a param then replace it with ^| in your batch ? (^ is the escape char)

GrahamQuote

(^ is the escape char)

Thanks Graham,

Code: [Select]MYPROG 'http://somewher.org/something.cgi?fred=x1^|x2^|x3'
linuxcommand: URL sucessfully added
That's it


Discussion

No Comment Found