This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sftp progress showing ... 66% complete

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 < 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 < 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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]