home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7779 < prev    next >
Encoding:
Text File  |  1993-01-12  |  3.9 KB  |  85 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!world!aml
  3. From: aml@world.std.com (Andrew M Langmead)
  4. Subject: Re: *sigh* Yes, the eternal question: How do I run it under 4dos aga
  5. Message-ID: <C0rBop.ADq@world.std.com>
  6. Organization: The World @ Software Tool & Die
  7. References: <0L1PwB5w165w@cybrspc.UUCP> <1267@alsys1.aecom.yu.edu> <C0Jq2p.FDD@world.std.com> <1271@alsys1.aecom.yu.edu>
  8. Date: Tue, 12 Jan 1993 20:02:49 GMT
  9. Lines: 74
  10.  
  11. manaster@yu1.yu.edu (Chaim Manaster) writes:
  12.  
  13. >In article <C0Jq2p.FDD@world.std.com> aml@world.std.com (Andrew M Langmead) writes:
  14. >>In the DOS version, if you have 4DOS to execute the file FOO.PL with the
  15. >>perl interpreter, and add a parameter BAR (FOO BAR) the command that a
  16. >>actually gets executed is PERL.EXE FOO.PL BAR
  17. >>BAR is now available in the @ARGV array. Any options to perl itself can
  18. >>be specified on the first line as #!/usr/bin/perl -n
  19. >>or by explicitly starting the perl interpreter with the appropriate options
  20. >>PERL -n FOO.PL BAR
  21.  
  22. >I thought that the point of invoking the 4dos convention was that
  23. >the unix #! convention doesn't work in DOS.
  24.  
  25. MS-DOS only understands how to execute .COM and .EXE files.
  26. COMMAND.COM and 4DOS understand how to execute .BAT files, and for
  27. each line that starts a .COM or .EXE calls the MS-DOS exec() system
  28. call. (Slightly different than in Unix, in which /bin/sh or other
  29. interpreters may be started when a file is passed to exec().) With
  30. 4DOS's executable extention mechanism, 4DOS is trying to figure out
  31. what to pass to the exec() call (which has to be either .COM or .EXE)
  32.  
  33. The #! convention doesn't execute a program in MS-DOS, because MS-DOS
  34. does not execute based on an executable attribute, and does not
  35. decide how to execute based on the contents of the file. Since Perl
  36. runs on other systems that don't decide how to execute based on the
  37. first few bytes of a file it parses that line itself. (On Unix
  38. systems that don't support #!  (SysV based) if the file has the
  39. executable bit set, but isn't machine code it is passed to /bin/sh.)
  40. On the systems that automatically run /bin/sh on non-machine code
  41. files some messing around can be done to get the perl interpreter
  42. started in a way that is syntatically different, but very similar in
  43. theory to the @rem=...  method of having COMMAND.COM pass a perl
  44. script to PERL.EXE (See a perl/bourne script that starts 
  45.  
  46. #!/usr/bin/perl
  47. eval "exec /usr/bin/perl -S $0 $*"
  48.      if $running_under_some_shell;
  49.  
  50. or look at the man page for an expaination of what it is doing.)
  51.  
  52. >Also, if the perl script is named "howdy" with parameters firstname
  53. >and lastname then the command line would not refernce perl at all,
  54. >but only howdy, as in: howdy(.pl) firstname lastname, and
  55. >the only refernce to perl would be IN howdy but not on the command
  56. >line. This seems to contadict your above statement. What am I
  57. >misunderstanding?
  58.  
  59. The line SET .PL=c:\bin\perl.exe tells 4DOS every file that ends in
  60. .PL can be a the first word on a command line, and when one appears
  61. the file c:\bin\perl.exe should be run. The command line that is
  62. given to 4DOS is "howdy firstname lastname" but what 4DOS passes to
  63. exec() is "C:\BIN\PERL.EXE HOWDY.PL firstname lastname" because 4DOS,
  64. not MS-DOS is doing the translation. Perl then starts up, taking the
  65. filename HOWDY.PL has the file to execute, checks the first line for
  66. any command line options (because it can tell that it wasn't started
  67. by the "magic numbers" in the first few bytes of the file.)
  68.  
  69. >Thanks again for the help.
  70.  
  71. >Henry Manaster
  72.  
  73. >--
  74. >***************************************************************************
  75. >       Henry Manaster          *     EMail: manaster@yu1.yu.edu
  76. >       Brooklyn, NY            *
  77. >                                *
  78. >       Disclaimer: The above is not necessarily MY opinion nor that
  79. >                               of anyone else :-)  ????!
  80. >****************************************************************************
  81. >
  82.  
  83. -- 
  84. ----
  85.