Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where does scp output go

Status
Not open for further replies.

columb

IS-IT--Management
Feb 5, 2004
1,231
EU
I'm trying to write a wrapper for scp.
Version 1.0 goes
Code:
#I've edited out the bit that sets boxes to <host1>,<host2>..
for n in $(echo ${_boxes}|tr ',' ' ')
do
  scp $1 $n:$2 
done
works a treat.
What I'm trying for Version 1.1 has a more sophisticated output and looks like
Code:
for n in $(echo ${_boxes}|tr ',' ' ')
do
export n
scp $1 $n:$2 2>&1 | awk '{printf ENVIRON["n"]":";print}'
done
But all the output seems to disappear. Can I assume from this that scp is writing directly to tty? Whilst I have plenty of workrounds this has got me intreaged. Any ideas?

Columb Healy
 
Intreaguing question indeed.

But what kind of output are you talking about?
I can see 2 types of output that cannot be redirected:

1) Password prompt (if necessary at all)
It always goes to the screen. So it must be /dev/tty.

2) The progress indicator.
It just disappears if redirected, even with tee command.
My guess is that a command like isatty is used to determine whether it will be printed. But you would have to look into the source code to see if this guess is correct.

just my 2 Eurocents ...
 
hoinz
I was after the progress bit. You're idea of going to the source code is one of those 'why didn't I think of that' moments! Thanks for the prompt.

Having browsed the code I found this snippet
Code:
	if (!isatty(STDERR_FILENO))
		showprogress = 0;
In brief if it's not on a tty it's the equivalent of running wiht the -q flag. Oh well, I could amend the code and recompile but I hate running with non standard code so I'll live with it.


Columb Healy
 
Maybe you could run it under expect or something else that pretends to be a terminal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top