Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Running Perl SCripts in Wiin95 DOS prompt?

Posted on 1998-06-08
11
Medium Priority
?
210 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 80 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Six Sigma Control Plans

719 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