How do I make Perl scripts recognize parameters in the Win32 cmd console?

后端 未结 9 1222
时光说笑
时光说笑 2020-12-03 12:46

When I invoke my Perl scripts in the Windows environment without invoking perl first, the parameters are not passed to my script.

For example,



        
相关标签:
9条回答
  • 2020-12-03 13:29

    After fixing file association problem could not pass parameters. A user I support mistakenly associated .pl file extension with notepad after trying to run script from (Windows 7 Professional) command line for first time. Tried all the file association tricks and environment variable fixes to no avail. Uninstalled and reinstalled and tried 32 bit and 64 bit installations. Issue was only present on users profile.

    Finally went into the registry and simply deleted the key from

    HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command

    and added back via

    reg add HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command /ve /d "C:\strawberry\perl\bin\perl.exe \"%1\" %*" /f

    started passing parameters again Thanks "lucretius"

    0 讨论(0)
  • 2020-12-03 13:38

    I tried updating and associating .pl with the many different PERL entries in the registry that others have tried (.pl, Perl, PerlScript, pl_auto_file, Applications\perl.exe) and none of these worked. I'm running AS Perl 5.14.2 on Windows 7. I then noted that there was an entry for \Applications\perl5.14.2.exe in the registry and it was set to:

    "C:\Perl\bin\perl5.14.2.exe" "%1"
    

    Added the %* to this and then I was able to see data in @ARGV.

    I also noted that on some of these entries I had a command path entry of "C"\Perl64\..." from a previous 64 bit PERL that I'd installed earlier and uninstalled when I found out that 64 bit PERL isn't as nice with IIS 7 as 32 bit PERL is. So there are dangling installation remnants that are probably affecting things too.

    So the answer here is probably not a short one and is in simple words... "It depends..." (on your system and installation).

    0 讨论(0)
  • 2020-12-03 13:41

    I installed Perl 5.24.3 on Windows2016 and found the JAMS scheduler Agent Shell ignored the .pl extension as if it did not exist. All good from DOS desktop. The same config on Winows2008 worked fine. The registry entries created by that ActiveState Perl Install, matched Lucretius Post above, but do not apply globally to all users. Not the default system user for example. Logging in as the user the Shell will run as, and making the association helped.

    Ideally there would be a registry twig to make .pl assoc global ?

    0 讨论(0)
提交回复
热议问题