in reply to perl windows backtick problem

Thanks guys for the quick replies. And apologies for making it too general. Here is the code:
require Win32; Win32->import; my $patharg = $ARGV[0]; print "ARGV: [$patharg]\n"; $path = "\"" . Win32::GetShortPathName($patharg) . "\""; print "patharg: [$patharg]\n"; print "path: [$path]\n"; my $cmd = "$path\\disc"; print "Issuing cmd: [$cmd]\n"; my $op = `$cmd`; my $ret = $?; print "ret: [$ret], op: [$op]\n"; $cmd = "$path\\disc -v"; print "Issuing cmd: [$cmd]\n"; $op = `$cmd`; $ret = $?; print "ret: [$ret], op: [$op]\n" ####################
Output:
C:\Users\Administrator.ZEN>perl test.pl "C:\Program Files\GFN%$^#\CLI\ +bin" ARGV: [C:\Program Files\GFN%$^#\CLI\bin] patharg: [C:\Program Files\GFN%$^#\CLI\bin] path: ["C:\PROGRA~1\GFN%$^#\CLI\bin"] Issuing cmd: ["C:\PROGRA~1\GFN%$^#\CLI\bin"\disc] The system cannot find the path specified. ret: [256], op: [] Issuing cmd: ["C:\PROGRA~1\GFN%$^#\CLI\bin"\disc -v] ret: [0], op: [ Discovery Version: 7.2.10.0 <snip> ]
If I maually run the command without any args, it runs fine:
C:\Users\Administrator.ZEN>"C:\Program Files\GFN%$^#\CLI\bin"\disc Discovery Version: 7.2.10.0
I have to qualify the script with paths containing such special characters.

Replies are listed 'Best First'.
Re^2: perl windows backtick problem
by Anonymous Monk on Sep 22, 2011 at 08:40 UTC