Re: KSH: Alternative shell interpreter path ?
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: Fri, 24 Jun 2005 15:03:14 -0400
On 2005-06-24, Thorsten Knopel wrote:
> i like to use a ksh script on difference System e.g. Linux and UnixWare.
> On both systems the shell has another path. for example for Linux :/opt/bin/ksh and for UnixWare
> /bin/ksh. Now i want that i can run the ksh script on both maschines without the normal commando
> like "/opt/bin/ksh my_kshscript.sh"
> I know i can write the line
> into my script. But for both system ? I tried to put 2 lines in the script but it didnt work
> Have you any ideas ?
> Sure i can work around with other scripts, but this is bad because i had change to many.
On a POSIX system, you can use:
#! /usr/bin/env ksh
Or (if you use the name ksh93):
#! /usr/bin/env ksh93
Better is to write your scripts in a portable manner, so that they
can be run by any POSIX shell.
Or you can write an script to add the correct shebang line when you
install the it on any machine.
-- Chris F.A. Johnson <http://cfaj.freeshell.org> ================================================================== Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress <http://www.torfree.net/~chris/books/cfaj/ssr.html>