calsaint has asked for the wisdom of the Perl Monks concerning the following question:
I am writing a program to take a backup of database. Want to zip database files. One way of doing that is, wait until the copy is done and then zip. But I would like to zip it while copying.
Would named pipes be a solution? Not sure how to use a named pipe in this situation...
Here is what I wrote, which does serial work, but want to make it to do those two in parallel:#!/usr/bin/perl use File::Copy; use POSIX; use Fcntl; use IPC::Open2; use File::Basename; $sourcedir = qq(/home/oranvad/ap/source); $targetdir = qq(/home/oranvad/ap/target); $file = qq(ijk); my $cpstat = ©File($file); print("\nfile=[$file]\tstatus=[$cpstat]"); sub copyFile() { my $fname = shift; my $cpcmd = qq(cp -p $sourcedir/$fname $targetdir/$fname); my $zpcmd = qq(zip $targetdir/$fname); print("\nCopying [$fname] with command [$cpcmd]..."); sleep(5); system("$cpcmd"); system("$zpcmd"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Zip files while copying
by ramprasad27 (Sexton) on Nov 16, 2011 at 02:56 UTC | |
|
Re: Zip files while copying
by ambrus (Abbot) on Nov 16, 2011 at 08:53 UTC | |
by aaron_baugher (Curate) on Nov 16, 2011 at 15:54 UTC | |
|
Re: Zip files while copying
by remiah (Hermit) on Nov 16, 2011 at 12:04 UTC | |
|
Re: Zip files while copying
by calsaint (Initiate) on Nov 16, 2011 at 17:46 UTC | |
|
Re: Zip files while copying
by calsaint (Initiate) on Nov 16, 2011 at 20:24 UTC |