home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!nwnexus!Celestial.COM!ray
- From: ray@Celestial.COM (Ray Jones)
- Subject: Re: ?Determine shell from withing a program?
- Organization: Celestial Software, Mercer Island, WA
- Distribution: us
- Date: Mon, 04 Jan 1993 19:45:39 GMT
- Message-ID: <1993Jan04.194539.6557@Celestial.COM>
- References: <1993Jan3.052413.22316@netcom.com>
- Lines: 41
-
- In <1993Jan3.052413.22316@netcom.com> gary@netcom.com (Gary Messenbrink) writes:
-
- >Hi again,
- >When I asked this question before, I apparently did not give
- >enough background information. I have a program that
- >outputs a string that is to be executed by a shell. It
- >currently works only for ksh. An example follows.
- > eval `program`
- >This causes program to execute and produce a string which
- >then gets passed to the shell for processing.
- >The problem is that I do not know how to determine what shell
- >was usedto invoke the eval command. The program is to be
- >distrbuted to other machines on a network where it will not be
- >possible for me to enforce what shell is in use. I do not want
- >to have a difference version of the program for each shell.
- [stuff deleted]
- >Garyi
-
- You can force a script to be run by a particular shell by including a header
- line in the script itself. In your example:
- eval `program`
- the file "program" would need one of the following lines as the first line
- #!/bin/ksh # to force Korn shell
- #!/bin/sh # to force Bourne shell
- #!/bin/csh # to force C-shell
-
- you will have to make sure the the shell of choice is in the same place on
- all the machines where it is to run. If you don't have Korn on all the
- machines and can run a Bourne shell script, put
- :
- as the first line of the script. This will force Bourne shell. And
- #
- as the first line will force C-shell. I don't know how to force Korn with
- other than #!/bin/ksh.
-
- Hope this helps.
- --
- INTERNET: ray@Celestial.COM Ray A. Jones; Celestial Software
- UUCP: ...!thebes!camco!ray 6641 East Mercer Way
- uunet!camco!ray Mercer Island, WA 98040; (206) 947-5591
- The probability of one or more spelling errors in this missive approaches
-