home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / shell / 5243 < prev    next >
Encoding:
Text File  |  1993-01-04  |  2.1 KB  |  53 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!nwnexus!Celestial.COM!ray
  3. From: ray@Celestial.COM (Ray Jones)
  4. Subject: Re: ?Determine shell from withing a program?
  5. Organization: Celestial Software, Mercer Island, WA
  6. Distribution: us
  7. Date: Mon, 04 Jan 1993 19:45:39 GMT
  8. Message-ID: <1993Jan04.194539.6557@Celestial.COM>
  9. References: <1993Jan3.052413.22316@netcom.com>
  10. Lines: 41
  11.  
  12. In <1993Jan3.052413.22316@netcom.com> gary@netcom.com (Gary Messenbrink) writes:
  13.  
  14. >Hi again,
  15. >When I asked this question before, I apparently did not give
  16. >enough background information.  I have a program that
  17. >outputs a string that is to be executed by a shell.  It
  18. >currently works only for ksh.  An example follows.
  19. >    eval `program`
  20. >This causes program to execute and produce a string which
  21. >then gets passed to the shell for processing.
  22. >The problem is that I do not know how to determine what shell
  23. >was usedto invoke the eval command.  The program is to be
  24. >distrbuted to other machines on a network where it will not be
  25. >possible for me to enforce what shell is in use.  I do not want 
  26. >to have a difference version of the program for each shell.
  27. [stuff deleted]
  28. >Garyi
  29.  
  30. You can force a script to be run by a particular shell by including a header
  31. line in the script itself.  In your example:
  32.     eval `program`
  33. the file "program" would need one of the following lines as the first line
  34. #!/bin/ksh        # to force Korn shell
  35. #!/bin/sh        # to force Bourne shell
  36. #!/bin/csh        # to force C-shell
  37.  
  38. you will have to make sure the the shell of choice is in the same place on
  39. all the machines where it is to run.  If you don't have Korn on all the
  40. machines and can run a Bourne shell script, put 
  41. :
  42. as the first line of the script.  This will force Bourne shell.  And
  43. #
  44. as the first line will force C-shell.  I don't know how to force Korn with
  45. other than #!/bin/ksh.
  46.  
  47. Hope this helps.
  48. -- 
  49. INTERNET:  ray@Celestial.COM   Ray A. Jones; Celestial Software
  50. UUCP:   ...!thebes!camco!ray   6641 East Mercer Way
  51.              uunet!camco!ray   Mercer Island, WA 98040; (206) 947-5591
  52. The probability of one or more spelling errors in this missive approaches
  53.