dcsimg
question to Runtime.exec()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   andre_schulte
Posted On:   Tuesday, November 6, 2001 12:19 AM

Hi Folks, I try to execute a shellscript like testtrack.sh with the exec command on Readhat Linux 7.1 Seawolf. It works. Files will be moved by the shellcommand, but only if I have at least one of the following both printlines in the sourcecode. System.out.printl ("Data:"+datainput.read()); and System.out.println("test"+datainput2.read()); If I delete the both printlines the shell script will not be execute, but I don`t see that the files will be moved. If I execute the javacode for example 5 times nothing happens if the printlines are missing in the sourcecoe. If I add one printline and I execute the javacode then I can see one actually moved file    More>>

Hi Folks,

I try to execute a shellscript like testtrack.sh with the exec command
on Readhat Linux 7.1 Seawolf.
It works. Files will be moved
by the shellcommand, but only if I have at least one of the following both printlines in the sourcecode.
System.out.printl ("Data:"+datainput.read());
and
System.out.println("test"+datainput2.read());

If I delete the both printlines the shell script will not be execute, but
I don`t see that the files will be moved.
If I execute the javacode for example 5 times nothing happens if the printlines
are missing in the sourcecoe. If I add one printline and I execute the javacode then I can see one actually moved file and abrupt the other past 5 files of the previous execution with no reaction. What is the reason for this
behaviour ????

Thank you for the help,

André


Here is the Sourcecode.

Process process = Runtime.getRuntime().exec("testtrack.sh");

InputStream inputstream = process.getErrorStream();
DataInputStream datainput = new DataInputStream(inputstream);
System.out.println("Data:"+datainput.read());

InputStream inputstream2 = process.getInputStream();
DataInputStream datainput2 = new DataInputStream(inputstream2);
System.out.println("test"+datainput2.read());

process.destroy();

Here is the shell script, very simple!
!/bin/sh
mv *.sbg /cc/cruisecontrol1.2.1a/

   <<Less

Re: question to Runtime.exec()

Posted By:   Nathan_Meyers  
Posted On:   Tuesday, November 6, 2001 07:15 PM

Why are you setting up DataInputStreams from your subprocess's output? Those are meant to read data in a binary format generated by a DataOutputStream - your shell script certainly isn't generating such output. Maybe you should try getting rid of the new DataInputStream() declarations.
About | Sitemap | Contact