allelopath
asked on
line continuation in Window XP CLI (cmd.exe)
I'm trying to create a batch file to execute a java program. The command is long due to the program arguments. I read that ^ is the line continuation for a batch file, but that doesn't work:
java -jar sall.jar ^
argument1 ^
argument2 ^
argument3 ^
argument4
What can I do?
java -jar sall.jar ^
argument1 ^
argument2 ^
argument3 ^
argument4
What can I do?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is output of your test:
Did it work?
Volume in drive C has no label.
Volume Serial Number is 51DC-0FA0
Directory of c:\
File Not Found
Did it work?
Volume in drive C has no label.
Volume Serial Number is 51DC-0FA0
Directory of c:\
File Not Found
ASKER
dragon:
I checked at your behest, but no spaces after the ^
The first argument is accepted. The error i get is:
argument2
is not recognized as an internal or external command,
operable program or batch file.
argument3
is not recognized as an internal or external command,
operable program or batch file.
argument4
is not recognized as an internal or external command,
operable program or batch file.
I checked at your behest, but no spaces after the ^
The first argument is accepted. The error i get is:
argument2
is not recognized as an internal or external command,
operable program or batch file.
argument3
is not recognized as an internal or external command,
operable program or batch file.
argument4
is not recognized as an internal or external command,
operable program or batch file.
Can you specify what the actual commands you are putting in are... perhaps there is something in there that is causing it to stop the line. I presume we are just talking paths/filenames here?
Clearly the problem also is with the argument1 line and/or the ^ on the end of that line.
Steve
Clearly the problem also is with the argument1 line and/or the ^ on the end of that line.
Steve
BTW copying and pasting your example version works for me... with the addtion of echo so I can not have to run java:
echo java -jar sall.jar ^
argument1 ^
argument2 ^
argument3 ^
argument4
returns
C:\>echo java -jar sall.jar argument1 argument2 argument3 argument4
java -jar sall.jar argument1 argument2 argument3 argument4
Steve
echo java -jar sall.jar ^
argument1 ^
argument2 ^
argument3 ^
argument4
returns
C:\>echo java -jar sall.jar argument1 argument2 argument3 argument4
java -jar sall.jar argument1 argument2 argument3 argument4
Steve
ASKER
>>I presume we are just talking paths/filenames here
Yes, an argument is something like:
"C:\some\directory with\ spaces in the name\"
Yes, an argument is something like:
"C:\some\directory with\ spaces in the name\"
ASKER
oops, argument is something like:
"C:\some\directory with\ spaces in the name"
(no \ at the end)
"C:\some\directory with\ spaces in the name"
(no \ at the end)
ASKER
tried these, but no difference:
"C:\\some\\directory with\\ spaces in the name"
"C:/some/directory with/ spaces in the name"
"C:\\some\\directory with\\ spaces in the name"
"C:/some/directory with/ spaces in the name"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you post the exact command that is giving you problems? Also, can you post any error messages that are reported?
Steve while we wait for allelopath what I get is
java -jar sall.jar ^
"C:\some\directory with\ spaces in the name" ^
"C:\some\directory with\ spaces in the name" ^
"C:\some\directory with\ spaces in the name"
Would append the first argument to the java line then try then execute the last two lines as another command. if the first character on a line is a " then it seems to stop it working as a continuation so I always add a space before the " if quotes are needed. For some wacky reason though the space isn't needed on the last line, even if there is a quote at the beginning of the line.
I've never come across any docs that shows this facility, I stumbled across it in a pre-written batch file ages ago and have used it now and again. Do you have any docs that show how it's supposed to work?
Steve
java -jar sall.jar ^
"C:\some\directory with\ spaces in the name" ^
"C:\some\directory with\ spaces in the name" ^
"C:\some\directory with\ spaces in the name"
Would append the first argument to the java line then try then execute the last two lines as another command. if the first character on a line is a " then it seems to stop it working as a continuation so I always add a space before the " if quotes are needed. For some wacky reason though the space isn't needed on the last line, even if there is a quote at the beginning of the line.
I've never come across any docs that shows this facility, I stumbled across it in a pre-written batch file ages ago and have used it now and again. Do you have any docs that show how it's supposed to work?
Steve
Well isn't that interesting. I found that this worked:
java -jar sall.jar ^
"1^" ^
"2^" ^
"3^"
java -jar sall.jar ^
"1^" ^
"2^" ^
"3^"
Odd isn't it, hadn't tried your combination but at least thats two workarounds then hopefully for him now anyway :-)
Steve
Steve
I missed your work around. What was it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And that allows all the lines to be treated as one?
Always has for me, odd eh!
e.g.
echo java -jar sall.jar ^
"argument 1" ^
"argument 2" ^
"argument 3" ^
"argument 4"
ends up running
C:\>echo java -jar sall.jar "argument 1" "argument 2" "argument 3" "argument 4"
java -jar sall.jar "argument 1" "argument 2" "argument 3" "argument 4"
Steve
e.g.
echo java -jar sall.jar ^
"argument 1" ^
"argument 2" ^
"argument 3" ^
"argument 4"
ends up running
C:\>echo java -jar sall.jar "argument 1" "argument 2" "argument 3" "argument 4"
java -jar sall.jar "argument 1" "argument 2" "argument 3" "argument 4"
Steve
Yes, I see. That is another solution. It wasn't clear to me in your last posted whether this worked for all the arguments :)
And you can get rid of the extra spaces like this:
echo Multiple lines with quoteed parameters^
"1"^
"2"^
"3"
echo Multiple lines with quoteed parameters^
"1"^
"2"^
"3"
Good point, never thought of that....
Wonder if alleopath is still with us :-)
Steve
Wonder if alleopath is still with us :-)
Steve
Excellent split <--- sarcasm intended. You made the list allelopath, good luck on your future questions...
Yes allelopath, choice is yours of course but if you have a couple of solutions given, disappear and don't give any feedback it's courteous to at least split the points between the people helping...
thanks for the points to me anyway.
Steve
thanks for the points to me anyway.
Steve
@echo off
dir ^
/ad ^
c:\temp
Are any syntax errors generated when you run your processing? I guess I'm trying to ask why you think it doesn't work.