locked
Execute file without file extension RRS feed

  • Question

  • I'm trying to execute a perl script (from the command prompt, I'm running Vista x64 and have ActivePerl x64 installed). When the perl script has a .pl file extension, it will execute. But when the perl script doesn't have a file extension, I just get the message

    'scriptname' is not recognized as an internal or external command,
    operable program or batch file.


    I also tried './scriptname', but got the error

    '.' is not recognized as an internal or external command,
    operable program or batch file.


    It works fine with no file extension in Linux. Is it possible to get the file to execute with no file extension in Windows?

    (I did originally ask this question in the Microsoft Answers forum , but it was suggested I ask here instead)

    Thanks

    Dave
    Tuesday, January 5, 2010 8:09 AM

Answers

  • Dave,
         In all my years working on Windows, I cannot remember a time that Windows allowed you to run/execute a file without an extension. You have to have a file extension so that Windows knows what application/runtime environment it knows to call to execute your script.

    Have you tried running the ActivePerl runtime and specifying the name of the script afterwards?

    thanks
    Tanner --- This is posted as-is and has no warranty or guarantee ---
    • Marked as answer by djeyewater Tuesday, January 26, 2010 2:54 PM
    Tuesday, January 26, 2010 10:22 AM

All replies

  • Dave,
         In all my years working on Windows, I cannot remember a time that Windows allowed you to run/execute a file without an extension. You have to have a file extension so that Windows knows what application/runtime environment it knows to call to execute your script.

    Have you tried running the ActivePerl runtime and specifying the name of the script afterwards?

    thanks
    Tanner --- This is posted as-is and has no warranty or guarantee ---
    • Marked as answer by djeyewater Tuesday, January 26, 2010 2:54 PM
    Tuesday, January 26, 2010 10:22 AM
  • Thanks for the info, I guess the problem is that Windows doesn't respect the shebang line, and doing some searching, it doesn't seem like it's possible to make Windows respect it.

    I would have thought Windows' reliance on file extensions could cause problems since two different programs might try to associate themselves with the same file extension, but can't say I've ever heard of this being an issue in real life.

    Dave
    Tuesday, January 26, 2010 2:54 PM
  • Hey DJ - Tanner S isn't entirely right.

    Yes, your perl scripts will need to retain their .PL extension, as Windows does not respect the shebang.

    However, once you have Perl set up and associated with .PL files, you can add .PL to the PATHEXT environment variable, which you can get to in the Advanced tab of System Properties.  Then you will be able to execute perl scripts without having to specify the .PL extension in the command (just like normal executable files, bat files, etc).
    Wednesday, February 24, 2010 9:13 PM
  • Thanks guys! This is really helpful. I couldn't find this information on any other site. There was one, which was trying to teach you how to plug in .bat file with Perl script to execute Perl script as a command, but it was so uninteresting.

    I just modified the PATHEXT variable, added the location of my script directory in PATH variable and it works!!

     

    Cheers.

    Sumeet Grover.

    Monday, January 24, 2011 12:48 PM
  • Thanks guys! This is really helpful. I couldn't find this information on any other site. There was one, which was trying to teach you how to plug in .bat file with Perl script to execute Perl script as a command, but it was so uninteresting.

    I just modified the PATHEXT variable, added the location of my script directory in PATH variable and it works!!

     

    Cheers.

    Sumeet Grover.

    Monday, January 24, 2011 12:48 PM