#!/usr/bin/perl

Discussion in 'Perl Misc' started by Roman Khutkyy, Dec 9, 2003.

  1. 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?
     
    Roman Khutkyy, Dec 9, 2003
    #1
    1. Advertising

  2. Roman Khutkyy wrote:
    > 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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Dec 9, 2003
    #2
    1. Advertising

  3. Roman Khutkyy

    ko Guest

    Roman Khutkyy wrote:
    > 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
     
    ko, Dec 9, 2003
    #3
  4. ko schrieb:
    > Roman Khutkyy wrote:
    >
    >> 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).
     
    Karlheinz Weindl, Dec 9, 2003
    #4
  5. Yes it works when you are using ISS, but under Apache it needs correct path.

    "Gunnar Hjalmarsson" <> wrote in message
    news:br42ds$25robq$-berlin.de...
    > Roman Khutkyy wrote:
    > > 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.
    >
    > --
    > Gunnar Hjalmarsson
    > Email: http://www.gunnar.cc/cgi-bin/contact.pl
    >
     
    Roman Khutkyy, Dec 9, 2003
    #5
  6. Roman Khutkyy

    Dave Saville Guest

    On Tue, 9 Dec 2003 10:37:02 +0200, Roman Khutkyy wrote:

    >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
     
    Dave Saville, Dec 9, 2003
    #6
  7. Roman Khutkyy

    Matt Garrish Guest

    "Karlheinz Weindl" <> wrote in message
    news:br47ko$4ok$...
    > ko schrieb:
    > >
    > > 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
     
    Matt Garrish, Dec 9, 2003
    #7
  8. Roman Khutkyy <> wrote:

    > 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.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Dec 9, 2003
    #8
  9. Roman Khutkyy

    Dominic Guest

    Dave Saville wrote:

    > On Tue, 9 Dec 2003 10:37:02 +0200, Roman Khutkyy wrote:
    >
    >
    >>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
    >
    >

    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
     
    Dominic, Dec 9, 2003
    #9
  10. Matt Garrish schrieb:

    > "Karlheinz Weindl" <> wrote in message
    > news:br47ko$4ok$...
    >
    >>ko schrieb:
    >>
    >>>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.
     
    Karlheinz Weindl, Dec 9, 2003
    #10
  11. Roman Khutkyy wrote:
    > Gunnar Hjalmarsson wrote:
    >> Roman Khutkyy wrote:
    >>> 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.

    >
    > 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

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Dec 9, 2003
    #11
  12. Roman Khutkyy

    Scott Yanoff Guest

    Roman Khutkyy wrote:

    > 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.

    --
    -Scott
    | http://www.yanoff.org | AOL IM: SAY KJY
     
    Scott Yanoff, Dec 9, 2003
    #12
  13. Roman Khutkyy

    l v Guest

    Gunnar Hjalmarsson wrote:
    > Roman Khutkyy wrote:
    >
    >> 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.
    >


    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
     
    l v, Dec 10, 2003
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Salerno
    Replies:
    30
    Views:
    1,970
    Stephan Kuhagen
    Aug 10, 2006
  2. Yves Dorfsman

    #!/usr/bin/env python vs. #!/usr/bin/python

    Yves Dorfsman, May 2, 2008, in forum: Python
    Replies:
    27
    Views:
    2,011
    Tim Roberts
    May 10, 2008
  3. anne001
    Replies:
    1
    Views:
    478
  4. joe
    Replies:
    8
    Views:
    199
    Matthias Weckman
    Nov 14, 2003
  5. Gilles
    Replies:
    7
    Views:
    563
    Matej Cepl
    Sep 30, 2012
Loading...

Share This Page