| re: Win32::Process - gunzip and output
Paolo wrote:[color=blue]
> 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");[/color]
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 $?";
[color=blue]
> 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...[/color]
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 |