Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Im using WindowsXP and i want to run the following command:

tomcat6 //IS//AlfrescoTomcat --DisplayName="Alfresco Community Edition" \ 
--Description="Alfresco Tomcat Bundle - Repository and Share" \
--Install="C:\alfresco-community-tomcat-3.3\tomcat\bin\tomcat6.exe" \
--Startup="auto" \
--Jvm="C:\Program Files\Java\jdk1.6.0_18\jre\bin\server\jvm.dll" \
--Classpath="C:\alfresco-community-tomcat-3.3\tomcat\bin\bootstrap.jar" \
--StartMode=jvm --StopMode=jvm --StartClass=org.apache.catalina.startup.Bootstrap \
--StartPath="C:\alfresco-community-tomcat-3.3" --StartParams=start \
--StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop \
--JvmMs=256 --JvmMx=1024 --JvmSs=1024 \
++JvmOptions="-Dcatalina.home=C:\alfresco-community-tomcat-3.3\tomcat" \
++JvmOptions="-Dcatalina.base=C:\alfresco-community-tomcat-3.3\tomcat" \
++JvmOptions="-Djava.endorsed.dirs=C:\alfresco-community-tomcat-3.3\tomcat\endorsed" \
++JvmOptions="-Djava.io.tmpdir=C:\alfresco-community-tomcat-3.3\tomcat\temp" \
++JvmOptions="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" \
++JvmOptions="-Djava.util.logging.config.file=C:\alfresco-community-tomcat-3.3\tomcat\conf\logging.properties" \
++JvmOptions="-XX:MaxPermSize=256m" \
++JvmOptions="-XX:NewSize=256m" \
++JvmOptions="-Dalfresco.home=C:\alfresco-community-tomcat-3.3" \
++JvmOptions="-Dcom.sun.management.jmxremote=true"

As this is a long command with lots of parameters being passed, i created a batch file to run it,but it only executes the first line,every other line is being executed as a separate command. Is there a way to run the whole command together ?

Thank You

share|improve this question

3 Answers 3

Windows uses the caret character (^) as its line continuation character, not a backslash. If you replace the backslashes at the end of each line with a caret, it will run as one command.

share|improve this answer
    
Sorry, but that only works if you enable delayed expansion, which you didn't mention. –  djangofan Dec 7 '11 at 18:10
    
pastebin.com/FpKjZNRT -- seems to work just fine without enabledelayedexpansion. –  ThatGraemeGuy Dec 8 '11 at 13:55

Why would you need linebreaks if it's going into a batch file? Remove those (and the \ characters), and just turn on word wrapping to make it easier to edit.

share|improve this answer
1  
Try debugging such a line. Having multiple lines for this makes it much easier. –  SvW Jun 30 '10 at 8:19

First of all, using DELAYEDEXPANSION, and advanced topic, you can combine separate lines into a single string within a batch file using the carrot character, to make your batch file prettier.

But, the quick way would be to add the string arguments all together into one string variable called MYARGS (minus the tomcat.exe prefix) . Then, the concatenated variable MYARGS is equal to the entire string of your command line arguments, then you can do processing to check the length of the command, using a DOS batch file and then run it, like so:

@echo off
setlocal ENABLEDELAYEDEXPANSION
:: additional content here
:: ....
set #=%MYARGS%
set length=0
:loop
if defined # (
  set #=%#:~1%
  set /A length += 1
  goto :loop
)
if %length% GTR 8191 (
  echo MYARGS is %length% characters long.  The total length of environment variable after you
  echo expand them cannot contain more than 8191 characters under Windows 2003+
  GOTO :end
) else if %length% GTR 2047 (
  echo MYARGS is %length% characters long.  The total length of environment variable after you
  echo expand them cannot contain more than 2047 characters under Windows XP
  GOTO :end
)
:startit
tomcat6.exe %MYARGS%
:end
pause
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.