3

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

Kara Marfia
  • 7,892
  • 5
  • 33
  • 57

3 Answers3

4

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.

Zombo
  • 1
  • 1
  • 16
  • 20
ThatGraemeGuy
  • 15,473
  • 12
  • 53
  • 79
0

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.

Dentrasi
  • 3,752
  • 1
  • 24
  • 19
  • 1
    Try debugging such a line. Having multiple lines for this makes it *much* easier. – Sven Jun 30 '10 at 08:19
0

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
djangofan
  • 4,182
  • 10
  • 46
  • 59