Solved

Running Perl SCripts in Wiin95 DOS prompt?

Posted on 1998-06-08
11
173 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now