Discussion:
[JSch-users] stdout and stderr question
Offer Baruch
2016-09-06 09:47:07 UTC
Permalink
Hi everyone,

We have been using JSCH for a long time now...
We are using an ChannelExec to run our commands.
Up until now we always read both the input and err streams and combined
their output into one string.

We now want to split those streams into different strings and to allow the
calling program to decide what to do with each stream...
When i tried to debug this, i have found that reading from the input stream
returns back both stdout and stderr... in fact the err stream is empty...
is this a known feature/bug?

is there a proper way to do this?

thanks in advance!
Offer Baruch
Offer Baruch
2016-09-28 10:35:26 UTC
Permalink
Really? no one? is this the right place to ask this?
Post by Offer Baruch
Hi everyone,
We have been using JSCH for a long time now...
We are using an ChannelExec to run our commands.
Up until now we always read both the input and err streams and combined
their output into one string.
We now want to split those streams into different strings and to allow the
calling program to decide what to do with each stream...
When i tried to debug this, i have found that reading from the input
stream returns back both stdout and stderr... in fact the err stream is
empty...
is this a known feature/bug?
is there a proper way to do this?
thanks in advance!
Offer Baruch
Keith Alan Richardson
2016-09-28 12:42:13 UTC
Permalink
Hi

Is the command you run remotely via jsch writing to stderr? You can check
that by running it manually and redirecting stdout to /dev/null

I recall the JSCH website has example code which reads the two streams out
separately. Try looking at that for a reference

If all else fails you'll need to share your code

-Keith Richardson
Post by Offer Baruch
Really? no one? is this the right place to ask this?
Post by Offer Baruch
Hi everyone,
We have been using JSCH for a long time now...
We are using an ChannelExec to run our commands.
Up until now we always read both the input and err streams and combined
their output into one string.
We now want to split those streams into different strings and to allow
the calling program to decide what to do with each stream...
When i tried to debug this, i have found that reading from the input
stream returns back both stdout and stderr... in fact the err stream is
empty...
is this a known feature/bug?
is there a proper way to do this?
thanks in advance!
Offer Baruch
Offer Baruch
2016-09-28 17:26:05 UTC
Permalink
Hi...

Thanks for the reply...
Yes. I am sure the command is writing to stderr... running the same command
with runtime.exec produces each output in a different stream...
I have read the examples and can't figure out anything i am doing wrong...

I will share the relevant parts of the code when i am near a computer
again...

Thanks on advance,
Offer Baruch
Post by Keith Alan Richardson
Hi
Is the command you run remotely via jsch writing to stderr? You can check
that by running it manually and redirecting stdout to /dev/null
I recall the JSCH website has example code which reads the two streams out
separately. Try looking at that for a reference
If all else fails you'll need to share your code
-Keith Richardson
Post by Offer Baruch
Really? no one? is this the right place to ask this?
Post by Offer Baruch
Hi everyone,
We have been using JSCH for a long time now...
We are using an ChannelExec to run our commands.
Up until now we always read both the input and err streams and combined
their output into one string.
We now want to split those streams into different strings and to allow
the calling program to decide what to do with each stream...
When i tried to debug this, i have found that reading from the input
stream returns back both stdout and stderr... in fact the err stream is
empty...
is this a known feature/bug?
is there a proper way to do this?
thanks in advance!
Offer Baruch
Loading...