karlika
asked on
Strange behaviour of scp
Hi!
I have some strange behaviour of the scp.exe (Cygwin on Win2k)
When I start the Programm manually on the Commandline it gives me some fine output (percentage, eta, speed ...)
But when I try to start the same thing in a java-process (via Runtime.exec())
neither the output nor the error stream give me any data.
scp itself works fine, meaning the file is successfully transfered, and the streams are closed afterwards.
But where is my output?
Anyone a clue?
Bye,
marko
I have some strange behaviour of the scp.exe (Cygwin on Win2k)
When I start the Programm manually on the Commandline it gives me some fine output (percentage, eta, speed ...)
But when I try to start the same thing in a java-process (via Runtime.exec())
neither the output nor the error stream give me any data.
scp itself works fine, meaning the file is successfully transfered, and the streams are closed afterwards.
But where is my output?
Anyone a clue?
Bye,
marko
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well, Im allready doing this.
It worked fine until I switched to a newer Version of cygwin.
The only thing I get now from output.readLine() and error.readLine() is null.
Regards,
Marko
It worked fine until I switched to a newer Version of cygwin.
The only thing I get now from output.readLine() and error.readLine() is null.
Regards,
Marko
I'm not familiar with scp.exe. You don't have to run an additional shell interpreter do you? i.e. something like
scp.exe sh <some shell script>
?
scp.exe sh <some shell script>
?
ASKER
Oke, it does not seem to be a Java Problem, since the command:
scp [some options] > testout 2>&1
Which should print every output into the testout file delivers an empty file.
But, how does the output come to the screen if not over the standard output and error -streams?
And how can I access this output?
Regards,
Marko
scp [some options] > testout 2>&1
Which should print every output into the testout file delivers an empty file.
But, how does the output come to the screen if not over the standard output and error -streams?
And how can I access this output?
Regards,
Marko
ASKER
No, you just call the programm directly.
No additional interpreters should be involved...
No additional interpreters should be involved...
Does the simpler
scp [some options] > testout
work?
scp [some options] > testout
work?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So basically, check that
returnValue = pro.waitFor();
(or whatever you have) returns 0
returnValue = pro.waitFor();
(or whatever you have) returns 0
ASKER
BAAAD scp.
Im using the output to draw a download progress bar, so the exit code does not really help me.
Anyone know another windows scp implementation which works with SSH 2?
I used pscp before but it doesnt support ssh2 identity files, which I am bound to use.
Regards,
marko
Im using the output to draw a download progress bar, so the exit code does not really help me.
Anyone know another windows scp implementation which works with SSH 2?
I used pscp before but it doesnt support ssh2 identity files, which I am bound to use.
Regards,
marko
> But, how does the output come to the screen if not over the standard output and error -streams?
Its probably using a different stream than stdout or stderr.
Its probably using a different stream than stdout or stderr.
ASKER
Im just checking the filesize periodically to power my progress bar...
Thanks for your comments
Thanks for your comments
heres another example of redirecting process output. It sends it to a text area but modifying to update a progress bar would be a simple change.
http://www.objects.com.au/java/examples/util/SwingExec.do
You just need to work out where scp is sending its output.
http://www.objects.com.au/java/examples/util/SwingExec.do
You just need to work out where scp is sending its output.
>> But, how does the output come to the screen if not over the standard output and error -streams?
It will use stderr/stdout. You will probably have to ditch the stream redirection in the command itself,handling it instead with Java
It will use stderr/stdout. You will probably have to ditch the stream redirection in the command itself,handling it instead with Java
:-)
CommandRunner.main(new String[] { "scp.exe", "arg1", "arg2" });