Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to make changes to a script that used to run on WInNT and now I Waana run that script On UNIX. I have a following piece of code in current program
Win32::Process::Create($process, "md5", "md5 $IdocFileName $IdocMd5FileName", 0, DETACHED_PROCESS, ".") or die "Create failed: ", Error();
I want to rewrite this piece of code so it will work in UNix. Is there similar module for UNIX. Please give any suggestion.

Replies are listed 'Best First'.
Re: From WinNT to Unix
by jwest (Friar) on Apr 17, 2001 at 18:14 UTC
    Well, I'm not sure what the side effects of Win32::Process::Create are, but generally speaking, you can get the same effect by using the system() function.

    system("md5 $IdocFileName $IdocMd5FileName &") and die "System failed";

    Another approach is to use fork() to create a process, and exec() the process you want it to run.
    my @pids; my $pid; if ($pid = fork()) { # Parent process push(@pids, $pid); } else { # Child process exec('md5', $IdocFileName, $IdocMd5FileName); exit; # This should never be reached. } ... # Clean up the children later... foreach $pid (@pids) { waitpid($pid); }
    system() handles most of this for you, though.

    Hope this helps!

    --jwest
    -><- -><- -><- -><- -><-
    All things are Perfect
        To every last Flaw
        And bound in accord
             With Eris's Law
                HBT; The Book of Advice, 1:7