sftp progress showing ... 66% complete

Robert Body rbody99@hotmail.com
Sat Dec 10 21:02:00 GMT 2005

Thanks for the input, Brian, I was trying to have the script re-direct 
output to a file (well actually just the final command of _time_ command was 
what mattered), but I guess that meant the sftp progress % went to a file 
too, but strange thing is, the other Stdout messages like "Uploading..." and 
"chdir" went to screen normally.

So I got rid of of my   2>&1 and tee  in my 3 files deep script call, and I 
did this:

start=`perl -e "print time;"`
end=`perl -e "print time;"`
perl -e "\$alpha=($end-$start); print \$alpha.\"s\";" > $tempFileTime   # 
end time - start time

I don't know how to handle X-Y in shell itself (nor how to get clock-ticks 
since 1970/1/1), so i just send it to Perl and have it get clock-ticks at 
start, at the end and I get the difference, and that's like the output from 
_time_ (measuring how long $mycommand took)  and this way by including 
"progress" in the input file to   sftp   i get to see the progress 
%percentage during transfer :-)


>From: Brian Dessent <brian@dessent.net>
>Reply-To: cygwin@cygwin.com
>To: cygwin@cygwin.com
>Subject: Re: sftp progress showing ... 66% complete
>Date: Sat, 10 Dec 2005 01:33:50 -0800
>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.
>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/

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/

More information about the Cygwin mailing list