Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spawning cmd scripts

 
Aaron Ehrensberger
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm spawning a .cmd script from within my main java app. Inside that script, it's setting up some values, then trying to spawn another java program. I don't believe that the 2nd java program is executing or returning to the calling script and then the 1st script hangs.

The code to call the initial script....

Process p = Runtime.getRuntime().exec(updateFile);

// Create threads to read the output and error streams.
OutputWriter errorWriter= new OutputWriter(p.getErrorStream(), "ERROR");
OutputWriter outputWriter = new OutputWriter(p.getInputStream(), "OUTPUT");
// Start the threads.
errorWriter.start();
outputWriter.start();

result = p.waitFor();


This code calls a script that contains a line ...


cd /D %LEADERBOARD_HOME%\server\leaderboard\deploy\Leaderboard.ear

java -classpath %classpath% com.smg.common.utils.MSSQLDSFileEditor %LEADERBOARD_HOME%\server\leaderboard\deploy %RegValue2% %RegValue3% %RegValue4%


Calling this script directly from a command prompt works fine, so I know that the script is working, but somewhere when java calls the script to call java, I'm missing something.

Is this possible? What am I missing?

Thanks,
Aaron
[ October 25, 2004: Message edited by: Aaron Ehrensberger ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps your script doesn't know the variables, like '%LEADERBOARD_HOME%'. ?
They aren't 'inherited' from the environment automatically.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic