Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: forking in winblows ?

by arkamedis21 (Acolyte)
on Apr 25, 2002 at 16:31 UTC ( [id://162022]=note: print w/replies, xml ) Need Help??


in reply to Re: forking in winblows ?
in thread forking in winblows ?

The dir command is just a simplified example on what is causing the problem in my larger script, and I don't think this has to do anything with the file system because if i was to replace:

my @output = `$dir_cmd`;

with a system call

system("$dir_cmd");

it works with even a 100 process's in parallel, the reason I son't want to use a system call is because I want to get the output and store it within a file

I even looked trying something like this:

system ("$dir_cmd >> out.txt");

but the output comes all mangled up, with so many process's trying to write to the same file at once, so I just store the output in a variable, and then copy it to the file within the smae child process, and it works for me in UNIX.

Replies are listed 'Best First'.
Re: Re: Re: forking in winblows ?
by Mr. Muskrat (Canon) on Apr 25, 2002 at 16:52 UTC
    So why not put the commands into a batch file and pipe the output of the commands to a file?
    test.bat -------- dir c:\some\path\ >>c:\path\to\test.txt
    then use the system call and read the output in perl:
    system("c:\path\to\test.bat"); open(OUTPUT, "<c:/path/to/test.txt") || die "couln't open ...yadda..." +; @output=<OUTPUT>; close(OUTPUT);

    Just my $0.02.

    Matthew Musgrove
    Who says that programmers can't work in the Marketing Department?
    Or is that who says that Marketing people can't program?
Re: Re: Re: forking in winblows ?
by graff (Chancellor) on Apr 26, 2002 at 05:52 UTC
    I even looked trying something like this:
    system ("$dir_cmd >> out.txt");
    but the output comes all mangled up, with so many process's trying to write to the same file

    Did you try something like this:

    system( "$dir_cmd > out$i.txt" );
    so that each thread would write to a different output file?

    Or, since you just want to read output from commands that are running in subshells, have you looked at creating an array of file handles that open "$dir_cmd |"? I haven't tried it, but I expect it would be possible (maybe even really simple) to loop over that array of handles doing non-blocking reads until their all done. (But I'm not running my windows partition just now, so I'd have to try it some other time...)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://162022]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-24 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found