hrm. sorry I don't know that much about perl.

Thanks,
Brad Davis
Cyberport Station

Eric Whiting wrote:

> Thanks for the info.
>
> I have used the shell redirection stuff to capture stdout/stderr from
> programs. But this time I'm trying to do a parallel rsync from a single
> server to multiple clients all at the same time. The server has 2G RAM
> and can handle the concurrent rsyncs.
>
> My problem is probably a perl programming problem and not a rsync one,
> but the 'log' feature in rsync would help me a lot. The following
> skeleton of perl shows what I'm trying to do. The perl 'open' command is
> really a popen system call that starts a child process to handle the
> rsync.
>
> The reason I wanted to use the rsync logfile feature is it seems the
> children and parent all share the same stdout and the individual '>>'s
> don't catch the right output. If I start a parallel rsync to 8 hosts,
> all the stdout gets mangled.
>
> Any other ideas?
> eric
>
> FROM THE PERLIPC MAN PAGE
>
>  Filehandles
>
>        Both the main process and any child processes it forks
>        share the same STDIN, STDOUT, and STDERR filehandles.  If
>        both processes try to access them at once, strange things
>        can happen.
>
> FROM MY ATTEMPT AT A PARALLEL RSYNC IN PERL
>
> foreach $dir (@dirs)  {
> # inner loop hosts -- do these all in parallel (at the same time)
>   foreach $host (@hosts) {
>
>     $cmd="/usr/local/bin/rsync -a --delete -e '/usr/local/bin/ssh '
> --log-format=\"$host %o %f %l %b\" --timeout 1800 $compress --exclude
> 'apps/.snapshot/*' /home/apps/${dir}  ${host}:/home/apps\n";
>
>     print "Working on $host  $dir\n";
>     open("$host","$cmd >>$log_dir/$host.log|");  # fork/sh/cmd magic is
> in the '|'
>   }
>
>   # wait for processes to finish -- blocks on the slow host -- zombies
> the others for a while
>   foreach $host (@hosts) {
>     while(<$host>) {
>     $data{$host}.=$_;  # try to save the data -- sure wish I could log
> to a fixed file instead.
>      }
>     close($host);
>   }
> }
>
> Brad Davis wrote:
> >
> > just add the > /place/where/thelogfiles/arestored .
> > Just direct the output to a file like that. Nice quick and dirty!
> >
> > Thanks,
> > Brad Davis
> > Cyberport Station
> >
> > Eric Whiting wrote:
> >
> > > I understand the log-format option for the rsync command:
> > >
> > >  --log-format=FORMAT     log file transfers using specified format
> > >
> > > I understand the log option for the rsyncd deamon.
> > >
> > >     log file
> > >
> > > What I want to do is log from the rsync command (not deamon) to a
> > > file. So far all I can get is my log format string written to stdout.
> > > How to I tell the rsync command to log to a file?
> > >
> > > I'd like this command to make a logifle in /tmp but it only writes the
> > > info to stdout.
> > > Is there a flag I'm missing? BTW I can't get all the % strings to work
> > > quite right in the command rsync but I get most of the important ones.
> > >
> > > Thanks,
> > > eric
> > >
> > > SAMPLE COMMAND:
> > >
> > > rsync -a --log /tmp/logfile --log-format "%o %f %l %b" /bin /tmp
> > >
> > > --
> > > __________________________________________________________________
> > > Eric T. Whiting                                 AMI Semiconductors
> > > (208) 234-6717                                  2300 Buckskin Road
> > > (208) 234-6659 (fax)                            Pocatello,ID 83201
> > > [EMAIL PROTECTED]


Reply via email to