Runtime.getRuntime().exec() ??

A

Andrew Regan

I'm using Process runner = Runtime.getRuntime().exec( cmdArgs );
where cmdArgs {"/bin/sh", "-c", <perl program>}.

If <perl program> is "/opt/vr/bin/show_active_servers" I can get the input
stream and read what the perl program outputs as follows. In fact it works
for any of the 4 programs in /opt/vr/bin directory.

BufferedReader is = new BufferedReader(new
InputStreamReader(runner.getInputStream()));
while((line = is.readLine()) != null){
System.out.println(line);
}

However if I change the program to "/opt/vr/etc/vr_report" I can't read any
of the programs output. No exceptions are thrown. The exit level of the
process is 0. I have tried inserting waitFors(). The perl programs are all
chmoded the same and are owned by the same user. I have also tried reading
from stderror and can't get any of the programs output. I have timed the
programs and the times seem to indicate that the java program is executing
the perl program, but I can't read any of its output?

Any ideas?

Thanks for your help,
Andrew Regan
 
S

Steve Horsley

Andrew said:
I'm using Process runner = Runtime.getRuntime().exec( cmdArgs );
where cmdArgs {"/bin/sh", "-c", <perl program>}.

If <perl program> is "/opt/vr/bin/show_active_servers" I can get the input
stream and read what the perl program outputs as follows. In fact it works
for any of the 4 programs in /opt/vr/bin directory.

BufferedReader is = new BufferedReader(new
InputStreamReader(runner.getInputStream()));
while((line = is.readLine()) != null){
System.out.println(line);
}

However if I change the program to "/opt/vr/etc/vr_report" I can't read any
of the programs output. No exceptions are thrown. The exit level of the
process is 0. I have tried inserting waitFors(). The perl programs are all
chmoded the same and are owned by the same user. I have also tried reading
from stderror and can't get any of the programs output. I have timed the
programs and the times seem to indicate that the java program is executing
the perl program, but I can't read any of its output?

Any ideas?

Thanks for your help,
Andrew Regan
Have you tried reading the error stream?
I suspect you will find somethig there.

Steve
 
Y

Yu SONG

Andrew Regan said:
I'm using Process runner = Runtime.getRuntime().exec( cmdArgs );
where cmdArgs {"/bin/sh", "-c", <perl program>}.

If <perl program> is "/opt/vr/bin/show_active_servers" I can get the input
stream and read what the perl program outputs as follows. In fact it works
for any of the 4 programs in /opt/vr/bin directory.

BufferedReader is = new BufferedReader(new
InputStreamReader(runner.getInputStream()));
while((line = is.readLine()) != null){
System.out.println(line);
}

However if I change the program to "/opt/vr/etc/vr_report" I can't read any
of the programs output. No exceptions are thrown. The exit level of the
process is 0. I have tried inserting waitFors(). The perl programs are all
chmoded the same and are owned by the same user. I have also tried reading
from stderror and can't get any of the programs output. I have timed the
programs and the times seem to indicate that the java program is executing
the perl program, but I can't read any of its output?

Any ideas?

If "any of the 4 programs in /opt/vr/bin directory" works while
"/opt/vr/etc/vr_report" don't, I think there may be something wrong with
your perl programs. (e.g in "/opt/vr/etc/vr_report")

You can have a look at the differences between these perl programs(i.e.
methods writing to stdout, some variables, etc.) and see what could happen.


--
Song

/* E-mail.c */
#define User "Yu.Song"
#define At '@'
#define Warwick "warwick.ac.uk"
int main() {
printf("Yu Song's E-mail: %s%c%s", User, At, Warwick);
return 0;}

Further Info. : http://www.dcs.warwick.ac.uk/~esubbn/
_______________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top