Home arrow static arrow Java Programming [Archive] - Runtime rt = Runtime.getRuntime();
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Runtime rt = Runtime.getRuntime();
This topic has 2 replies on 1 page.

Posts:183
Registered: 8/25/99
Runtime rt = Runtime.getRuntime();  
Aug 4, 2004 3:15 PM



 
The following should kick off the script my_script.sh in /var/a/db directory. I have a bunch of echo commands in the script but looks like the echo commands are not working because when the script is kicked off, I don't see any of the echo messages in standard output. Any ideas why?

try {
String executeCommand = "/var/a/db/scripts/my_script.sh";
System.out.println("Execute command : " + executeCommand);
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(executeCommand);
proc.waitFor();
} catch (Exception e) {
System.out.println(e.toString());
}

Content of my_script.sh :

#!/usr/bin/ksh

echo "Staring script my_script.out"
echo "Creating file myoutput.out"
echo "DONE" > myoutput.out
echo "Removing file myoutput.out"
rm -f myoutput.out

The file "myoutput.out" is created...... however, it's never removed and none of the echo statements to standard output is printed.

 

Posts:2,206
Registered: 8/15/02
Re: Runtime rt = Runtime.getRuntime();  
Aug 4, 2004 3:17 PM (reply 1 of 2)



 
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 

Posts:183
Registered: 8/25/99
Re: Runtime rt = Runtime.getRuntime();  
Aug 5, 2004 7:17 AM (reply 2 of 2)



 
Thanks EvilEdna. That was very helpful.
 
This topic has 2 replies on 1 page.