Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script intended for multiple systems....

Status
Not open for further replies.

stillflame

Programmer
Jan 12, 2001
416
the "#!/..." line at the beginning of a script points to the location of perl. what do you put to be able to use the same script on two different systems, each with a different path (or, in this case, file system. it's to go from *nix to win9x and back again every day)?
i vaugely remember something in one of the readme files on porting that come with the perl source, in which there was some sort of wrapper or something, but couldn't find it now, when i actually needed to know it. i looked through perldocs too, but to no avail...
thanks for any help.
stillflame "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
the #! shebang has no meaning on Win32 platform.

The only way to tell your script where perl is located is to associate the .pl extension with your perl interpreter.

Or call it directly from the perl interpreter like this:

C:\> perl myscript.pl

The other option is to use the pl2bat utility on your script:

C:\> pl2bat myscript.pl

will create a DOS batch file which will do everything, so you just type:

c:\> myscript.bat

to execute it.

Perl is not the greatest language to be switching between platforms with. If you plan on doing alot of this you might want to consider Java. Perl was designed to be a scripting language that Unix sysadmins can use to automate rudimentary administration tasks. It was never really meant to be used on other platforms.

Java, on the other hand, was designed for that type of thing.

Regards,
Gerald
 
ah... thanks

it's only on a win32 machine for testing/editing while away from the office and home(which is fairly rare). they're just a few cgi scripts, and before now i had just been manually switching the shebang line before using it on this foreign. i didn't know it didn't matter.

thanks again "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
"Perl was designed to be a scripting language that Unix sysadmins can use to automate rudimentary administration tasks."

<smile>

Well yes, but it's a lot more than that now. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Use the shebang line on Win32 if you are doing something like

#! /usr/local/bin/perl -w

The Win32 version picks up the &quot;command line&quot; options that are present.
 
The shebang is not needed on Win32 systems running IIS or PWS but it IS required when running Apache under Windows. I have not found a way around changing it each time a file is moved from Win32 Apache to a Unix/Linux server. but would be happy to know if there is a way.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top