sftp progress showing ... 66% complete

Brian Dessent brian@dessent.net
Sat Dec 10 21:29:00 GMT 2005

Robert Body wrote:

> 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.

Okay, it makes a lot more sense what you are trying to do now.  There
are several much better ways (IMHO) to do this.

Firstly, if you use /bin/time instead of the shell builtin 'time'
command, you can specify both a format and an output file:

/bin/time -f "%e seconds elapsed" -o /tmp/timelog \
   sftp who@where.com < fileWithActions

What you're doing now ends up calling perl three times.  If you're going
to use perl you might as well just call perl once and do everything
there, since it is far more powerful than screwing around with
head/tail/expr/etc (which are very inefficient ways to process text
since you fork/exec a process for each operation):

perl -e 'use Time::HiRes qw(time); $start = time;
   system("sftp who@where.com < fileWithActions");
   printf "%.2f seconds elapsed\n", time - $start;'

This allows for any kind of formatting of the output you desire, as well
as better-than-second granularity.


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