Solved

Running Perl SCripts in Wiin95 DOS prompt?

Posted on 1998-06-08
11
196 Views
Last Modified: 2010-03-05
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
Comment
Question by:rickyr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1207711
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
 
LVL 51

Accepted Solution

by:
ahoffmann earned 20 total points
ID: 1207712
@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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1207713
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
Independent Software Vendors: 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!

 
LVL 6

Expert Comment

by:alamo
ID: 1207714
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1207715
alamo, how do you run it in a command.com, or from within another program?
0
 
LVL 6

Expert Comment

by:alamo
ID: 1207716
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
 
LVL 6

Expert Comment

by:alamo
ID: 1207717
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1207718
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
 
LVL 3

Author Comment

by:rickyr
ID: 1207719
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1207720
try without  -S  option:

perl.exe %0 %ARGS%

also make shure that perl.exe is in your PATH, or use full pathname.
0
 
LVL 3

Author Comment

by:rickyr
ID: 1207721
Hi...
It worked for the first suggestion "-S", after I edited my PATH
thanx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
crawling gofundme 4 144
perl script to check whether folder contains any files 5 98
Regex rule to match two different url 5 76
Log File Creation with Header and Footer 17 155
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question