#!/usr/bin/perl

R

Roman Khutkyy

Hi all,
is there any ability in Perl to write the first string in script as
alternative string for different platforms.
I write CGI scripts on the Win32 computer, then I transport it to the Unix
server, and each time i need to rewrite this string. Is there universal
string for both platforms?
 
G

Gunnar Hjalmarsson

Roman said:
is there any ability in Perl to write the first string in script as
alternative string for different platforms.
I write CGI scripts on the Win32 computer, then I transport it to
the Unix server, and each time i need to rewrite this string. Is
there universal string for both platforms?

On my Win32 computer, I have a C:/usr/bin directory where I have an
extra copy of perl.exe. That makes '#!/usr/bin/perl' work there as well.
 
K

ko

Roman said:
Hi all,
is there any ability in Perl to write the first string in script as
alternative string for different platforms.
I write CGI scripts on the Win32 computer, then I transport it to the Unix
server, and each time i need to rewrite this string. Is there universal
string for both platforms?

If you're using Active State Perl you can keep the shebang line intact -
its ignored, *except* for any switches.

'perldoc perlrun' ('Description' section) describes this behavior.

HTH - keith
 
K

Karlheinz Weindl

ko said:
Roman said:
Hi all,
is there any ability in Perl to write the first string in script as
alternative string for different platforms.
I write CGI scripts on the Win32 computer, then I transport it to the
Unix
server, and each time i need to rewrite this string. Is there universal
string for both platforms?

If you're using Active State Perl you can keep the shebang line intact -
its ignored, [...]

Not necessarily true. The OP transfers CGI scripts from Win32 to UNIX,
so presumably running Apache under Windows, which in turn requires the
shebang line to be present (and correct of course).
 
R

Roman Khutkyy

Yes it works when you are using ISS, but under Apache it needs correct path.
 
D

Dave Saville

Hi all,
is there any ability in Perl to write the first string in script as
alternative string for different platforms.
I write CGI scripts on the Win32 computer, then I transport it to the Unix
server, and each time i need to rewrite this string. Is there universal
string for both platforms?

One way is to use perl <command> on one platform and <command> on the
other. If you use the former and also have a shebang line perl will
obey the switches on it but not try and find the executable. At least
this is true for the 5.8.0 OS/2 port.


Regards

Dave Saville

NB switch saville for nospam in address
 
M

Matt Garrish

Karlheinz Weindl said:
ko said:
If you're using Active State Perl you can keep the shebang line intact -
its ignored, [...]

Not necessarily true. The OP transfers CGI scripts from Win32 to UNIX,
so presumably running Apache under Windows, which in turn requires the
shebang line to be present (and correct of course).

That's not entirely true either. You can specify to use the registry in your
Apache config file on Windows, and then just keep the shebang line for the
Unix system.

Matt
 
T

Tad McClellan

Roman Khutkyy said:
I write CGI scripts on the Win32 computer, then I transport it to the Unix


Use "ASCII" or "text" mode when you ftp the file.
 
D

Dominic

Dave said:
One way is to use perl <command> on one platform and <command> on the
other. If you use the former and also have a shebang line perl will
obey the switches on it but not try and find the executable. At least
this is true for the 5.8.0 OS/2 port.


Regards

Dave Saville

NB switch saville for nospam in address
Here's some advice I got from someone else (it works):

Under Windows, create c:\usr, and inside it c:\usr\bin.
Then copy perl.exe from c:\perl\bin to c:\usr\bin.
Now all your scripts - on both platforms - can start with
#!/usr/bin/perl

- Dom
 
K

Karlheinz Weindl

Matt said:
ko said:
If you're using Active State Perl you can keep the shebang line intact -
its ignored, [...]

Not necessarily true. The OP transfers CGI scripts from Win32 to UNIX,
so presumably running Apache under Windows, which in turn requires the
shebang line to be present (and correct of course).


That's not entirely true either. You can specify to use the registry in your
Apache config file on Windows, and then just keep the shebang line for the
Unix system.

You are absolutely right.
Admittedly I didn't recognize ScriptInterpreterSource until you stubbed
me into it. But on my experience I believe for the purpose mentioned
(developing on Win and transfering to UNIX) the "mimiking an Unix file
system approach" has some advantages over using a "windowish" Apache
directive.
 
G

Gunnar Hjalmarsson

Roman said:
Yes it works when you are using ISS, but under Apache it needs
correct path.

I'm doing it with an Apache server on W98. Maybe I should mention that
the autoexec.bat file adds the path to the 'regular' perl bin with all
the perl related .exe and .bat files.

HTH
 
S

Scott Yanoff

Roman said:
Hi all,
is there any ability in Perl to write the first string in script as
alternative string for different platforms.
I write CGI scripts on the Win32 computer, then I transport it to the Unix
server, and each time i need to rewrite this string. Is there universal
string for both platforms?

I'm not sure if there is one that will work for both Unix and Windows,
but one thing I have seen in the past for the "she-bang" line is:

#!/usr/bin/env perl -w

Google groups search for "perl bin env" and you can find some examples
of this.
 
L

l v

Gunnar said:
On my Win32 computer, I have a C:/usr/bin directory where I have an
extra copy of perl.exe. That makes '#!/usr/bin/perl' work there as well.

Microsoft has a program called linkd.exe located on their resourse kit
which allows you to make a unix type symlink on NTFS. It allows to link
c:/usr/bin to your perl install location.

I could not find the Windows 2000 version on MS's web site but they do
have the Win 2003 version
http://download.microsoft.com/download/8/e/c/8ec3a7d8-05b4-440a-a71e-ca3ee25fe057/rktools.exe

Directory of C:\usr

12/09/2003 09:18 PM <DIR> .
12/09/2003 09:18 PM <DIR> ..
12/09/2003 09:18 PM <JUNCTION> bin


C:\usr>dir bin
Volume in drive C has no label.
Volume Serial Number is 5C27-E982

Directory of C:\usr\bin

08/24/2003 08:41 PM <DIR> .
08/24/2003 08:41 PM <DIR> ..
01/02/2002 04:17 PM 90,112 a2p.exe
05/28/2003 07:17 PM 38,124 c2ph.bat
12/28/2001 09:34 AM 5,154 config.pl
08/20/2001 10:09 AM 3,555 configPPM.pl
10/26/2001 01:06 PM 3,888 configPPM3.pl
01/02/2002 04:19 PM 21,820 dprofpp.bat
01/02/2002 04:19 PM 3,265 exetype.bat
05/28/2003 07:17 PM 24,172 find2perl.bat
05/28/2003 07:17 PM 20,708 h2ph.bat
05/28/2003 07:17 PM 49,506 h2xs.bat
08/20/2001 10:09 AM 1,820 IISScriptMap.pl
12/09/2002 01:40 AM 1,876 Keywords.txt
01/02/2002 04:23 PM 13,323 libnetcfg.bat
08/20/2001 10:31 AM 12,905 libnetcfg.pl
12/09/2002 01:42 AM 69,632 MSIdump.exe
12/09/2002 01:43 AM 106,496 pdkdebug.exe
01/02/2002 04:17 PM 20,480 perl.exe
01/02/2002 04:17 PM 20,480 perl5.6.1.exe
01/02/2002 04:17 PM 663,552 perl56.dll


Very handy tool.

Len
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top