tags:

views:

2391

answers:

3

I am trying to capture output from an install script (that uses scp) and log it. However, I am not getting everything that scp is printing out, namely, the progress bar.

screen output:

Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb

cdb@server's password: myfile 100% |*************************| 2503 00:00

log output:

Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb

I'd really like to know that my file got there. Here's what I am trying now to no avail:

myscript.sh 2>&1 | tee mylogfile.log

Does anyone have a good way to capture scp output and log it?

Thanks.

A: 

Maybe you can use 'script' to log the terminal session.

ayaz
+3  A: 

It looks like your just missing whether the scp was succesful or not from the log.

I'm guessing the scroll bar doesn't print to stdout and uses ncurses or some other kind of TUI?

You could just look at the return value of scp to see whether it was successful. Like

scp myfile [email protected]:. && echo success!

man scp says

scp exits with 0 on success or >0 if an error occurred.
Tarski
A: 

yes i recently was trying to get output within a php script from proc_open() i lost a quiet a time trying to get output :-) but its a bit late here and i then reading this post here made me realize that i dont really need this junky output to my script

just the exit code will do the job :-)

$exit_code = proc_close($process);

paranic