Re: [JSch-users] Checking the return error status of a remote command
Status: Alpha
Brought to you by:
ymnk
From: <ym...@jc...> - 2005-02-22 14:55:18
|
Hi, +-From: Ana Oprescu <ana...@gm...> -- |_Date: Tue, 22 Feb 2005 02:07:14 +0100 ______ | | Hello, I have tried to identify whether or not a remote command |yield an error, using the set/getErrStream, but no matter what i |did, the only thing i can do is to print the error message. |I tried the following: |InputStream err; Channel channel = session.openChannel("exec"); |((ChannelExec)channel).setCommand("dummy"); |((ChannelExec)channel).setErrStream(System.err); |channel.connect(); err = ((ChannelExec)channel).getErrStream(); |if(err.available() != 0) System.out.println("error"); That should be InputStream err; Channel channel = session.openChannel("exec"); ((ChannelExec)channel).setCommand("dummy"); err = ((ChannelExec)channel).getErrStream(); channel.connect(); if(err.available() != 0) System.out.println("error"); , but 'err.available() != 0' depends on the timining. You shoud wait for the termination of remote exec and then check 'err.available()'. Thanks, -- ymnk |