Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java Runtime getRuntime().exec not work in AIX

Reply
Thread Tools

Java Runtime getRuntime().exec not work in AIX

 
 
Roedy Green
Guest
Posts: n/a
 
      09-24-2011
On Fri, 23 Sep 2011 07:35:15 -0700 (PDT), SamuelXiao
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>
>String[] cmds =3D{"/bin/ksh","-c","uuenco


Start simple, say an echo command or whatever AIX uses to display a
text message.

Then gradually add the complexity.

If you can't even get that to work try running an executable rather
than a script.


See http://mindprod.com/jgloss/exec.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-26-2011
On Sat, 24 Sep 2011 10:59:19 +0200, Lars Enderin
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>Jag påminner om att "Try do" och liknande inte är korrekt engelska.
>Skriv "Try to (infinitiv)" eller "Try *ing". Alltså "Try to do that"
>eller "Try doing that".


From the name, the person you are talking to might speak Chinese, but
I doubt Swedish.
--
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

 
Reply With Quote
 
 
 
 
Andreas Leitgeb
Guest
Posts: n/a
 
      09-26-2011
Roedy Green <(E-Mail Removed)> wrote:
> On Sat, 24 Sep 2011 10:59:19 +0200, Lars Enderin
><(E-Mail Removed)> wrote, quoted or indirectly quoted someone
> who said :
>> Jag påminner om att "Try do" och liknande inte Àr korrekt engelska.
>> Skriv "Try to (infinitiv)" eller "Try *ing". Alltså "Try to do that"
>> eller "Try doing that".

> From the name, the person you are talking to might speak Chinese, but
> I doubt Swedish.


Lars merely gave Arne a brief English lesson

 
Reply With Quote
 
SamuelXiao
Guest
Posts: n/a
 
      09-26-2011
On Sep 23, 8:14*pm, Andreas Leitgeb <(E-Mail Removed)>
wrote:
> Arne Vajhøj <(E-Mail Removed)> wrote:
> > On 9/23/2011 10:35 AM, SamuelXiao wrote:
> >> String[] cmds ={"/bin/ksh","-c","uuencode /log/test.log attached.log|
> >> mailx -s 'Testing' (E-Mail Removed) "};
> >> System.out.println("Before process run");
> >> Process process = Runtime.getRuntime().exec(cmds);
> >> System.out.println("After process run");
> >> both message displayed, but the process really not running.

> > That code is not reading output and error from the process.

>
> What may be even more relevant than reading from channels
> that likely won't send data, anyway, is to call .waitFor()
> on the process returned by the .exec(...)-call, in order to
> ensure that "After process run" is really printed after the
> run, instead of already after merely being kicked off.
>
> Reading from the error channel, like Arne suggested, might
> still be a good idea - unless you really don't care about
> any failures of uuencode or mailx. *Logging errors could also
> be done by ">>/tmp/debug-uuencode-and-mailx.log 2>&1" added
> to the little ksh-script.


Hi all,

Thanks very much, the problem has been solved. After I added
p.waitfor() after .exec(cmds), the process run successfully. Although
I don't know why need to add waitfor() to it.

Thanks
 
Reply With Quote
 
Lars Enderin
Guest
Posts: n/a
 
      09-26-2011
2011-09-26 11:32, Andreas Leitgeb skrev:
> Roedy Green <(E-Mail Removed)> wrote:
>> On Sat, 24 Sep 2011 10:59:19 +0200, Lars Enderin
>> <(E-Mail Removed)> wrote, quoted or indirectly quoted someone
>> who said :
>>> Jag påminner om att "Try do" och liknande inte Àr korrekt engelska.
>>> Skriv "Try to (infinitiv)" eller "Try *ing". Alltså "Try to do that"
>>> eller "Try doing that".

>> From the name, the person you are talking to might speak Chinese, but
>> I doubt Swedish.

>
> Lars merely gave Arne a brief English lesson
>

Arne is a Dane. He understands written Swedish. I made a mistake. I
shouldn't have posted, just sent a personal message.

 
Reply With Quote
 
Andreas Leitgeb
Guest
Posts: n/a
 
      09-26-2011
SamuelXiao <(E-Mail Removed)> wrote:
>> >> String[] cmds ={"/bin/ksh","-c","uuencode /log/test.log attached.log |
>> >> mailx -s 'Testing' (E-Mail Removed) "};
>> >> System.out.println("Before process run");
>> >> Process process = Runtime.getRuntime().exec(cmds);
>> >> System.out.println("After process run");
>> >> both message displayed, but the process really not running.

>> What may be even more relevant [...] is to call .waitFor()
>> on the process returned by the .exec(...)-call,

>
> Thanks very much, the problem has been solved. After I added
> p.waitfor() after .exec(cmds), the process run successfully.
> Although I don't know why need to add waitfor() to it.


..exec(...) starts the child process,
..waitFor() lets the parent process wait, till the child process
has completed running.

Normally, the email should still be sent, even without .waitFor(),
but then it runs asynchronously to the parent process, which again
means, that the second println happens before the child process has
even had a chance to do anything. .waitFor() is merely synchronization.

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-26-2011
On 9/26/2011 5:27 AM, Roedy Green wrote:
> On Sat, 24 Sep 2011 10:59:19 +0200, Lars Enderin
> <(E-Mail Removed)> wrote, quoted or indirectly quoted someone
> who said :
>
>> Jag påminner om att "Try do" och liknande inte är korrekt engelska.
>> Skriv "Try to (infinitiv)" eller "Try *ing". Alltså "Try to do that"
>> eller "Try doing that".

>
> From the name, the person you are talking to might speak Chinese, but
> I doubt Swedish.


Amazing what one can find using this modern thing called
the internet:
http://en.wikipedia.org/wiki/.dk

Arne


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI program work with jdk 5 but not jdk6 on aix 5.3 TsanChung Java 4 09-26-2008 02:43 PM
JNI program work with 32bit but not 64bit JVM on jdk 1.6 & aix 5.3 TsanChung Java 7 09-18-2008 12:47 PM
putenv for AIX and ifdef for AIX ClownPleco C Programming 5 08-24-2007 02:15 PM
Looking for AIX 5.2 binaries, IS anyone running Ruby on AIX 5.2 ?? bww00amdahl@yahoo.com Ruby 5 07-08-2005 11:54 AM
sun java runtime for AIX? Alex Hunsley Java 5 11-06-2003 04:14 PM



Advertisments