delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/12/10/04:34:03

X-Spam-Check-By: sourceware.org
Message-ID: <439AA0FE.3DF2DD69@dessent.net>
Date: Sat, 10 Dec 2005 01:33:50 -0800
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: sftp progress showing ... 66% complete
References: <BAY104-F36C247120193300EA81572AD440 AT phx DOT gbl>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Robert Body wrote:

> ok it appears my problem is with my script, not sftp:
> 
> specifically with using tee or > in the command: (time $mycommand) 2>&1 |
> tee $tempFile

The sftp program, like many others (e.g. scp) will only output status
information if stdout is a tty.  When you redirect to a file this is not
the case.  The reason it does this is that interactive progress meters
like those used by most file transfer programs will look like gibberish
when redirected to a file, because they usually print repeated status
update lines every few seconds, using carriage returns to overwrite the
prior output without advancing a row on the screen.

You can get around this by using something like the 'script' utility,
which will provide a pseudoterminal (pty) to the program so that it
thinks it's being run interactively, but the output in fact goes to a
file.  However if you look at this output with something like 'less' it
will probably look like garbage because of all these repeated lines. 
Again, these programs are not intended to log their interactive outputs
to a file, so if you do this you will probably have to process the
output in some way if you want something readable.  However, if you
simply 'cat' the output to a terminal it will look perfectly normal
since in effect you are just playing back all these terminal sequences
in fast-forward.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019