damo666 has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I have been looking at a problem we have within our firm. We copy a large number of log files from our servers around the country. Currently we run a file copy file based on a list of servers. The problem we have comes when it comes to a server with a large log file and we have to wait for it to copy before it can move onto another server and start copying. I have looked at trying to run the copyfile program multiple times and so it copies 5 log file at one time. So when 1 of the 5 instances is complete it adds another instance so i and always copying data.
I have only just started looking at fork and have found some code that i have changed a bit but i cannot get it to change the variables sent to each process. I keep getting the same varibles sent and dont know why. Any idea. Code below.
@list=(srv1,srv2,srv3,srv3) for (1 .. $list_count) { print "Launching: Process $_$/"; defined(my $cpid = fork) or warn $! and next; $kid{$cpid} = undef, next if $cpid; my($server, $account, $path) = split /\t/,$list[$c]; $c++; my $proc = "$curdir"."program.exe $server".">$server.log"; exec $proc; exit 0; } delete $kid{wait()} while %kid; print "Done...$/";
Edited by planetscape - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running a program mulitple times with different Variables
by Corion (Patriarch) on Mar 14, 2006 at 11:57 UTC | |
|
Re: Running a program mulitple times with different Variables
by wazoox (Prior) on Mar 14, 2006 at 12:32 UTC | |
|
Re: Running a program mulitple times with different Variables
by rafl (Friar) on Mar 14, 2006 at 11:55 UTC |