Hi Georges,

 

Thanks a lot for your help.

I did the same:

 

 

public class CommandManager {

public static String getOutputCommand( String command ) throws Exception

{

      Process process = Runtime.getRuntime().exec( command );

      process.waitFor();

      BufferedReader in = new BufferedReader(new InputStreaReader(process.getInputStream()));

      String result = in.readLine();

      in.close();

      return result;

}

}

 

It works perfect when I use a local command on windows and unix.

It still works when the command is a ssh on windows.

But does not work anymore for a ssh command on unix. I don't get anything!

 

>>> print CommandManager.getOutputCommand("/usr/bin/ssh lalanne@mrs-dv-00001  cat ~/temp/result375.txt'" )

 

None

 

 

 

But, on windows:

 

>>> print CommandManager.getOutputCommand("C:\\cygwin\\bin\\ssh.exe lalanne@mrs-dv-00001 'cat temp/result.txt'")

 

Serena ChangeMan Dimensions 9.1.0 at 13:39:34 Wednesday 08 June 2005 Copyright

 

 

 

So, now I am totally blocked.

 

I don’t know how to get the output of my remote command …

The problem is that I need this output!

 

Any help will be really appreciated.

 

Regards

 

Jean-Guillaume LALANNE

 

 

-----Message d'origine-----
De : George Rogers [mailto:grogers@solution-soft.com]
Envoyé : mercredi 8 juin 2005 16:01
À : Jean Guillaume LALANNE
Cc : 'Carlos Garcia'; jython-users@lists.sourceforge.net
Objet : Re: [Jython-users] os.system and os.popen

 

I use Java directly to execute the command and get the output from the

Java exec method

as shown below.  You will probably want to change the command string

provided to the

exec command.

 

Hope this helps.

 

#

# function to look for an executable file in the search path and to

return its

# full path.  Uses the UNIX 'which' command and assumes UNIX OS

#

def getExecPath(prog):

    retPath = ''                        # set to return empty string

    cmdAr =  ('which', prog)

    rt = java.lang.Runtime.getRuntime()

    proc = rt.exec(cmdAr)

    isr = java.io.InputStreamReader(proc.getInputStream())

    bufferedReader = java.io.BufferedReader(isr)

    try:

        progInfo = bufferedReader.readLine();

        if progInfo.startswith('/'):

            # looks like the right type of information

            retPath = progInfo

    except:

        bufferedReader.close()

    else:

        bufferedReader.close()

    return retPath

 

George Rogers

 

Jean Guillaume LALANNE wrote:

 

>Hi,

> 

>I have to run in one of my script a native command line.

>I would like to get the output of this command.

>How can I do since popen function is not yet implemented in jython ?

> 

>Thanks in advance for your help.

> 

>Regards,

> 

>Jean-Guillaume LALANNE

> 

> 

> 

>-------------------------------------------------------

>This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput

>a projector? How fast can you ride your desk chair down the office luge track?

>If you want to score the big prize, get to know the little guy. 

>Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20

>_______________________________________________

>Jython-users mailing list

>Jython-users@lists.sourceforge.net

>https://lists.sourceforge.net/lists/listinfo/jython-users

>