By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,190 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,190 IT Pros & Developers. It's quick & easy.

Win32::Process - gunzip and output

P: n/a
There is something I can't understand which is the following.
I have a system command which runs a commandline to unzip a file:

my $Out = system ( $rootPath."bin/bin/gunzip -dfc ".
$SourceFilePath." > ".$rootPath.$DestinationPath.".txt");

This works fine.
since I would like to make it parallel and run 4 processes at a time I
wrote this code:

use Win32::Process;
my $cmdLine = " -dfc ".$SourceFilePath." >
".$rootPath.$DestinationPath.".txt";
my $Out = Win32::Process::Create(my $ProcessObj,
$rootPath."bin/bin/gunzip.exe",
$cmdLine,
1,
NORMAL_PRIORITY_CLASS, # or even
".") || die ErrorReport();

(really not rocket science!)

what happens is that gunzip, instead of creating an output file, it
prints to the stdout!!
I don't understand what's being screwed...
Sep 26 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Paolo wrote:
There is something I can't understand which is the following.
I have a system command which runs a commandline to unzip a file:

my $Out = system ( $rootPath."bin/bin/gunzip -dfc ".
$SourceFilePath." > ".$rootPath.$DestinationPath.".txt");
You really ought to simplify that. Most . concatenations are unneeded.
The first one is OK, but can be obviated by using "${variable}txt".
my $gunzip = "${rootPath}bin/bin/gunzip"
my $cmd="$gunzip -dfc $SourceFilePath >$rootPath$DestinationPath.txt";
print "$cmd\n" if $verbose;
system($cmd) == 0 or warn "system() failed; error code $?";
use Win32::Process;
my $cmdLine = " -dfc ".$SourceFilePath." >
".$rootPath.$DestinationPath.".txt";
my $Out = Win32::Process::Create(my $ProcessObj,
$rootPath."bin/bin/gunzip.exe",
$cmdLine,
1,
NORMAL_PRIORITY_CLASS, # or even
".") || die ErrorReport();
what happens is that gunzip, instead of creating an output file, it
prints to the stdout!!
I don't understand what's being screwed...


You're assuming that either Win32::Process::Create interprets ">" the
same way that CMD.EXE does. It doesn't. Either invoke CMD.EXE or
do the equivalent by redirecting STDOUT yourself.
-Joe
Sep 26 '05 #2

P: 18
For my own benifet, could you please explain why you are using Win32::Process and not threads? Thanks in advance! Oh, you might also find http://search.cpan.org/~nwclark/Perl...p-0.17/gzip.pm usefull
Oct 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.