[kw-pm] Using backticks in Perl script

Ryan Fox foxryan at gmail.com
Mon Feb 8 07:05:15 PST 2010


Perhaps you'd have better luck with a package from CPAN?
http://search.cpan.org/perldoc?IO::Uncompress::Gunzip

<http://search.cpan.org/perldoc?IO::Uncompress::Gunzip>I can't (be bothered
to) find if it's doing everything in Perl, or if it's calling a library
somewhere, but it should probably at least get around problems with system
calls.

2010/2/8 Quantum Mechanic <quantum.mechanic.1964 at gmail.com>

> On Tue, Feb 2, 2010 at 10:19 AM, Robert Pike <roberthpike at yahoo.com>wrote:
>
>> Hi All,
>>   I've been passed a script that does unzipping of files and I can't seem
>> to get it to work on a Windows machine. The server I'm trying this on I have
>> to VPN in to. I've commented out the code that is trying to unzip a file and
>> decided to put a simplier command in and see if I can get that to work but
>> still w/o success.
>>
>>   my $testStr = "dir";   #--- line 1
>>   my $newTest = `$testStr`;
>>   print "<br>Test string returned :" . $newTest . "<br>";
>>
>>   When I run the overall script I get errors on the third line of code
>> above telling me <name of script.pl>: Use of uninitialized value $newTest
>> in concatenation (.) or string at <name of script>.pl line 82.
>>   I'm trying this simplier example to see if I can get it working first,
>> the piece of code in the script (I was passed) is trying to use the gunzip
>> executable but w/o success (i.e. gunzip -cf <$filePath) using the backticks
>> again. Any help would be appreciated. Thanks.
>>
>
> "dir" is a builtin command, and doesn't exist anywhere as an executable by
> default. On my XP machine, I'd have to issue
>
>      cmd /c "dir"
>
> You would have the same problem on *nix with builtins if the shell didn't
> interpret them. For instance, `setenv` does nothing when called from perl,
> though it does from the command line.
>
> (However, I doubt that this is your original problem -- most likely you've
> created an unrelated problem by trying to make the script simpler.)
>
> --
> -QM
> Quantum Mechanics: The dreams stuff is made of
>
> _______________________________________________
> kw-pm mailing list
> kw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/kw-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/kw-pm/attachments/20100208/5413c45c/attachment.html>


More information about the kw-pm mailing list