Bug 1265

Summary: SCP progress doesn't map to standard out or standard error
Product: Portable OpenSSH Reporter: John Thiesfeld <junkmail>
Component: scpAssignee: Damien Miller <djm>
Status: CLOSED FIXED    
Severity: minor CC: vincent-openssh
Priority: P4    
Version: 4.4p1   
Hardware: PPC   
OS: AIX   
Bug Depends on:    
Bug Blocks: 1274    
Attachments:
Description Flags
check isatty(stdout) for progress meter dtucker: ok+

Description John Thiesfeld 2006-12-01 03:43:16 AEDT
When doing an scp using OpenSSH 4.4p1, 4.3p2 and 3.8 without mapping standard error or standard out to a file, the progress of a transfer is shown after the MOTD and password are entered.  If either standard out or standard error are written to a file, then the progress is lost.

$scp file foo@bar:       
foo@bar's password: 
file                                         100%  126     0.1KB/s   00:00


$scp file foo@bar: > log
foo@bar's password: 
$cat log
$


$scp file foo@bar: 2> log
foo@bar's password: 
$cat log
$
Comment 1 Damien Miller 2007-01-22 12:57:10 AEDT
Created attachment 1228 [details]
check isatty(stdout) for progress meter

This is a bug in scp. It checks for stderr being a TTY before displaying the progress meter, but actually writes the progress meter to stdout. So if either is redirected then the progress meter will not be displayed.

The attached patch makes the test and the writing consistent.
Comment 2 Darren Tucker 2007-01-22 13:06:25 AEDT
Comment on attachment 1228 [details]
check isatty(stdout) for progress meter

ok by me.

Personally I think the progress meter should go to stderr not stdout but since that's how it is (including for sftp) it probably doesn't make sense to change it now.
Comment 3 Darren Tucker 2007-02-19 23:19:51 AEDT
This has been fixed in OpenBSD and now -Portable.  The change will be in tomorrow's Portable snapshot and will be in the 4.6 release.

Thanks for the report.
Comment 4 Vincent Lefevre 2007-06-13 22:24:43 AEST
I think that the progress meter should be output to the terminal, not to stdout or stderr, which may be redirected. For instance:

$ ./scp -S $PWD/ssh scp.c localhost:
Enter passphrase for key '/home/vlefevre/.ssh/id_rsa': 
Connected to vin (from 127.0.0.1)
scp.c                         100%   28KB  27.6KB/s   00:00
$

That's OK. But:

$ ./scp -S $PWD/ssh scp.c localhost: < /dev/null >& /dev/null
Enter passphrase for key '/home/vlefevre/.ssh/id_rsa': 
$

I don't get the progress meter either if I use:

$ ./scp -S $PWD/ssh scp.c localhost: | cat

Since ssh knows how to display "Enter passphrase for key..." on the terminal, there shouldn't be any problem for the progress meter either.
Comment 5 Damien Miller 2008-04-04 09:57:29 AEDT
Close resolved bugs after release.