I'm writing a program that uses scp to copy files in a bigger java program. As it stands now, the program freezes up while the scp is copying the file, which can take a few minutes, so I'd like to be able to display the progress of the scp or at the very least get the terminal window with the scp progress to show up! Any suggestions?
scp
writes to STDOUT and flushes the output. If you pipe the output, you may be able to read the output from the pipe, but my guess is that 1) scp wont print the progress bar to a pipe or 2) if you can do 1, the output will only make sense if you re-implement a pty or similar in a java window.
However, you could experiment with an expect-like module calling scp and mimic how the terminal works and you may be able to fake scp into thinking its being run as a terminal.
Finally, (and this is probably the best answer), don't use scp, find a java library to import that directly links into openssh's protocols for transferring files with scp.
When you say, "the program freezes up", my guess is that you mean that a Swing UI freezes up. If so, launch scp in a background thread and show the user an indeterminate progress bar.
Invoke the "launch scp" using SwingWorker to get it of the main thread and let the GUI update again.
To get actual progress you will need to investigate the characters printed by scp. I believe it maintains an ASCII progress bar, you can then replicate in Java. You may want to add "-v" to scp to let it be more talkative.