I've tried this technique but unfortunately the thread priorities are
off such that the process doesn't interact well with the rest of my
script. Is there a way to up the priorities?
Thanks.
--bob w.
On Wed, Jun 08, 2005 at 04:36:09PM +0200, Jean Guillaume LALANNE wrote:
> Hi Georges,
>=20
> =20
>=20
> Thanks a lot for your help.
>=20
> I did the same:
>=20
> =20
>=20
> =20
>=20
> public class CommandManager {
>=20
> public static String getOutputCommand( String command ) throws Exceptio=
n
>=20
> {
>=20
> Process process =3D Runtime.getRuntime().exec( command );
>=20
> process.waitFor();
>=20
> BufferedReader in =3D new BufferedReader(new
> InputStreaReader(process.getInputStream()));
>=20
> String result =3D in.readLine();
>=20
> in.close();
>=20
> return result;
>=20
> }
>=20
> }
>=20
> =20
>=20
> It works perfect when I use a local command on windows and unix.
>=20
> It still works when the command is a ssh on windows.
>=20
> But does not work anymore for a ssh command on unix. I don't get
> anything!
>=20
> =20
>=20
>=20
> >>> print CommandManager.getOutputCommand("/usr/bin/ssh
> lalanne@... cat ~/temp/result375.txt'" )
>=20
> =20
>=20
> None
>=20
> =20
>=20
> =20
>=20
> =20
>=20
> But, on windows:
>=20
> =20
>=20
>=20
> >>> print CommandManager.getOutputCommand("C:\\cygwin\\bin\\ssh.exe
> lalanne@... 'cat temp/result.txt'")
>=20
> =20
>=20
> Serena ChangeMan Dimensions 9.1.0 at 13:39:34 Wednesday 08 June 2005
> Copyright
>=20
> =20
>=20
> =20
>=20
> =20
>=20
> So, now I am totally blocked.
>=20
> =20
>=20
> I don=92t know how to get the output of my remote command =85
>=20
> The problem is that I need this output!
>=20
> =20
>=20
> Any help will be really appreciated.
>=20
> =20
>=20
> Regards
>=20
> =20
>=20
> Jean-Guillaume LALANNE
>=20
> =20
>=20
> =20
>=20
> -----Message d'origine-----
> De : George Rogers [mailto:grogers@...
> Envoy=E9 : mercredi 8 juin 2005 16:01
> =C0 : Jean Guillaume LALANNE
> Cc : 'Carlos Garcia'; jython-users@...
> Objet : Re: [Jython-users] os.system and os.popen
>=20
> =20
>=20
> I use Java directly to execute the command and get the output from the=20
>=20
> Java exec method
>=20
> as shown below. You will probably want to change the command string=20
>=20
> provided to the
>=20
> exec command.
>=20
> =20
>=20
> Hope this helps.
>=20
> =20
>=20
> #
>=20
> # function to look for an executable file in the search path and to=20
>=20
> return its
>=20
> # full path. Uses the UNIX 'which' command and assumes UNIX OS
>=20
> #
>=20
> def getExecPath(prog):
>=20
> retPath =3D '' # set to return empty string
>=20
> cmdAr =3D ('which', prog)
>=20
> rt =3D java.lang.Runtime.getRuntime()
>=20
> proc =3D rt.exec(cmdAr)
>=20
> isr =3D java.io.InputStreamReader(proc.getInputStream())
>=20
> bufferedReader =3D java.io.BufferedReader(isr)
>=20
> try:
>=20
> progInfo =3D bufferedReader.readLine();
>=20
> if progInfo.startswith('/'):
>=20
> # looks like the right type of information
>=20
> retPath =3D progInfo
>=20
> except:
>=20
> bufferedReader.close()
>=20
> else:
>=20
> bufferedReader.close()
>=20
> return retPath
>=20
> =20
>=20
> George Rogers
>=20
> =20
>=20
> Jean Guillaume LALANNE wrote:
>=20
> =20
>=20
> >Hi,
>=20
> >=20
>=20
> >I have to run in one of my script a native command line.
>=20
> >I would like to get the output of this command.
>=20
> >How can I do since popen function is not yet implemented in jython ?
>=20
> >=20
>=20
> >Thanks in advance for your help.
>=20
> >=20
>=20
> >Regards,
>=20
> >=20
>=20
> >Jean-Guillaume LALANNE
>=20
> >=20
>=20
> >=20
>=20
> >=20
>=20
> >-------------------------------------------------------
>=20
> >This SF.Net email is sponsored by: NEC IT Guy Games. How far can you
> shotput
>=20
> >a projector? How fast can you ride your desk chair down the office lug=
e
> track?
>=20
> >If you want to score the big prize, get to know the little guy. =20
>=20
> >Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20
>=20
> >_______________________________________________
>=20
> >Jython-users mailing list
>=20
> >Jython-users@...
>=20
> >https://lists.sourceforge.net/lists/listinfo/jython-users
>=20
> > =20
>=20
> >=20
>=20
--=20
Robert Waldrop Motorola Personal Communications Sector
rwaldrop@... Urbana-Champaign Design Center
voice 217-384-8719 1800 South Oak Street
Champaign IL 61820
[X] Motorola General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
|