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


In reply to Running a program mulitple times with different Variables by damo666

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.