Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Running Perl SCripts in Wiin95 DOS prompt?

Hi...
I downloaded and installed Perl 5. The question is...
How do I get scripts to run the way I run them in Unix...

# chmod u+x myScript.
# myScript

I'm new to scripting on the PC, when I type the name of the file it says bad file name or command.

C:\ Perl -v #works fine
regards
0
rickyr
Asked:
rickyr
  • 5
  • 4
  • 2
1 Solution
 
alamoCommented:
Just like when you type the name of a text file Windows knows .txt means run notepad, you need to associate the extension  .pl with perl so Windows runs it when you type myScript.pl.

(Note that the .pl extension is required, Windows needs the extension to tell file type, unlike Unix which looks at the first line of the file no matter its name).

You can add the association of .pl to perl.exe in My Computer | View | Options | File Types. (There may be an easier way, but since most programs do it automatically I don't need to go ther often). Good Luck!
0
 
ahoffmannCommented:
@REM = '
@ECHO OFF
SET ARGS=
:loop
IF .%1==. GOTO endloop
SET ARGS=%ARGS% %1
SHIFT
GOTO loop
:endloop
perl.exe -S %0 %ARGS%
GOTO endofperl
@REM ';

print "  write your perl code here  \n";

__END__

:endofperl
SET ARGS=

0
 
ahoffmannCommented:
Oops, forgot to tell you that the script from my answer must be in a file with extension  .bat  (probably .exe or .com works too;-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
alamoCommented:
Ok, so why would you ever do it that way, rather than giving the script a .pl extension and running it directly? Or am I missing something?
0
 
ahoffmannCommented:
alamo, how do you run it in a command.com, or from within another program?
0
 
alamoCommented:
From the Command Prompt (which is actually cmd.exe, not command.com). I am actually running NT, but I could have sworn 95 has the same file association capabiolity (though I don't have a 95 machine handy to test with right now).
0
 
alamoCommented:
Oops.
Researching the issue, I find that while 95 can run files via file extension association same as NT when clicking on them, 95 can't do from a command prompt. I had not realized the 95 command shell lacked that capability. Sorry, ignore my original post.

(In researching this, I did also find a way in NT to run a perl script from the shell without specifying the extension, which I said above was impossible. Oops again).

Thanks for posting that answer, ahoffman, so I didn't waste rickyr's time. However, I am sorely tempted to ask him to reject your answer so I can post "Upgrade to WinNT as the real answer :-)
0
 
ahoffmannCommented:
command.com, cmd.exe  doesn't matter, it just works.
I'm trying to reject using of 95 ;-)
In the M$ world it's so cumbersome to do simple things like perl :-(( see my answer

0
 
rickyrAuthor Commented:
hi Ahoffman....
I tried it and got.....
C:\mydir myscript.bat
Can't execute myscript.bat.
Label not found
regards
P.S. If your back at work and have the time, I would still like to go thru mail setup for
standalone sparc with no DNS.
0
 
ahoffmannCommented:
try without  -S  option:

perl.exe %0 %ARGS%

also make shure that perl.exe is in your PATH, or use full pathname.
0
 
rickyrAuthor Commented:
Hi...
It worked for the first suggestion "-S", after I edited my PATH
thanx
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now