Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

System substitution2

by bitman (Beadle)
on Nov 20, 2002 at 14:12 UTC ( #214448=perlquestion: print w/ replies, xml ) Need Help??
bitman has asked for the wisdom of the Perl Monks concerning the following question:

Re: Getting perl to recognise imbedded spaces.
Thank you all for your help thus far. LTjake said my code worked for him, so I tried it again and it does work! The code actually runs from a PL2BAT file which is running an old version of Perl 5.005 though, this doesn't work, though 5.6.1 does work. Do you know why? I may need this to work on the old version for distribution to clients.
\\PRIMARY\PERL5005\BIN\perl -x -S "%0" %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. goto endofperl @rem '; #!perl -w $ENV{TYPE}=q("c:\scotts test\type me"); $new_debug_log=q("c:\scotts test\type me.bat"); my $rc = system("$ENV{TYPE} $new_debug_log"); __END__ :endofperl
The short-name lookup didn't appeal, thought very interesting

Comment on System substitution2
Download Code
Re: System substitution2
by BrowserUk (Pope) on Nov 20, 2002 at 15:14 UTC

    I don't have perl 5.005 to verify my speculation but have you tried using the other form of the system command?

    This allows you to avoid interpolation both within Perl and by the shell which greatly simplifies the quoting you need. The following works as is under 5.6.1 and may be better under 5.005?

    #!perl -w $ENV{TYPE}='c:\scotts test\type me'; $new_debug_log='c:\scotts test\type me.bat'; my $rc = system('cmd.exe', '/c', $ENV{TYPE}, $new_debug_log );

    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

Re: System substitution2
by bitman (Beadle) on Nov 20, 2002 at 15:46 UTC
    Doesn't work correctly under 5.005 either! B*gger!
    ----------------------------------------------------
    I don't have perl 5.005 to verify my speculation but have you tried using the other form of the system command? This allows you to avoid interpolation both within Perl and by the shell which greatly simplifies the quoting you need. The following works as is under 5.6.1 and may be better under 5.005?
    #!perl -w $ENV{TYPE}='c:\scotts test\type me'; $new_debug_log='c:\scotts test\type me.bat'; my $rc = system('cmd.exe', '/c', $ENV{TYPE}, $new_debug_log );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://214448]
Approved by fireartist
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-12-20 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (94 votes), past polls