Re: Calling a shell function

From: Amey Samant (ameyas7_at_yahoo.com)
Date: 10/06/03


Date: 6 Oct 2003 07:52:56 -0700


"John Bowling" <johnlb2002_TAKEOUT_@cox.net> wrote in message news:<dfXfb.51546$vj2.1114@fed1read06>...

hi John
java.lang.Runtime class should solve your problem
you can exec (no need to fork in java ;) its taken care of inside
exec) a command/program just the way you run it on your shell.
it creates a Process object & you can then get its
outputstream,inputsream to give input, output to the process.
the sequence is
invoke program
feed input to the Process
get the output from the Process

but the problem could arise if you invoke a program that has sequnce
of i/p,o/p , i/p , o/p & in random order with o/p in between
then you will not be able to see o/p unless your process has fifnished
& you read it.
that means if your program says "Enter a number : " & reads a number
then you will have to enter the number first & only when your program
is finished you shall see "Enter a number : " in its o/p :D
thus asynchronous i/o is not directly supported
i was writing a shell in java (as it can be then portable to all
platforms) but i got stuck with this, & i found that this can be
resolved only if you opt for JNI which makes the shell native :( . so
i dropped it altogether.
however i have seen some of shells written in java, i dont know if
they did use JNI or without it.

regards
amey



Relevant Pages

  • Re: detect shell script language
    ... In the 'old' days, when a user typed in a command, the interactive shell would immediately pass it off to 'exec' to execute. ... So, on return from exec with an error status, the shell would fork a copy of itself to try and run the script. ... As a result of the above, it was hard to tell whether the script was a Bourne shell or C shell, so the convention was introduced of using the Bourne shell no op command, as the first line in a Bourne shell script. ...
    (Debian-User)
  • Re: Is anything easier to do in java than in lisp?
    ... > cruel since Java is such a simple, powerless language, but c.l.l. ... which however are useless to me here on VT100 dialup into Unix shell. ... But where does expendable income come from? ... shell% kennyLabor | wageCalc ...
    (comp.lang.java)
  • Re: Is anything easier to do in java than in lisp?
    ... > cruel since Java is such a simple, powerless language, but c.l.l. ... which however are useless to me here on VT100 dialup into Unix shell. ... But where does expendable income come from? ... shell% kennyLabor | wageCalc ...
    (comp.lang.lisp)
  • Re: [SLE] Compiled a C program, cannot run by name
    ... Your current directory is not checked for executables in most ... And why should the DOS shell be derided for providing this ... > I did a man exec and it seems to be a bash script executor, ... When calling "exec ./myapp" the process image of the shell is replaced ...
    (SuSE)
  • Re: Java/LE Tuning Advice sought
    ... I'm afraid that the reports that you are seeing are from the parent shell and not the java process, ... your shell script is maybe using "iconv" pipes to convert output from java/jboss from ascii to ebcdic. ... You might be able to use _CEE_RUNOPTS settings to tell LE to write its "MSGFILE" somewhere else. ...
    (bit.listserv.ibm-main)