how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

Post by dwaynek.. » Fri, 13 Oct 2000 09:30:58



shell scripts normally have to run under the same shell or at the very
least, you have to specify say ksh shellscript...

how do i create a shell script that will rewrap itself to the correct
shell wrapper regardless of what shell the user runs it under?

so even if the user is under sh, the shell will auto-sense and put a
ksh wrapper on itself?

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

Post by Peter Sundstro » Fri, 13 Oct 2000 11:22:59



Quote:> shell scripts normally have to run under the same shell or at the very
> least, you have to specify say ksh shellscript...

Not true.

Quote:

> how do i create a shell script that will rewrap itself to the correct
> shell wrapper regardless of what shell the user runs it under?

> so even if the user is under sh, the shell will auto-sense and put a
> ksh wrapper on itself?

The she bang line #! tells the Unix kernel what command to process the file
with, whether it be

#!/bin/ksh
#!/usr/local/bin/perl
#!/usr/local/bin/expect

or even something silly like

#!/bin/cat

 
 
 

how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

Post by Faux_Pseu » Fri, 13 Oct 2000 04:00:00


--(Once apon a time, in comp.unix.admin,)--
                --(Peter Sundstrom said it like only they can.)--
Quote:

>#!/bin/ksh
>#!/usr/local/bin/perl
>#!/usr/local/bin/expect

>or even something silly like

>#!/bin/cat

i had never thought about using a non shell for the she bang line
that cat line was fun :)
not that i will ever find a good reson to use it

--
 ._______.                               ._______.
 | <> <> |     GUI's are for slackers.   | <> <> |
  \-|o|-/   ibpconf.sh on freshmeat.net   \-|o|-/
   /___\   the easiest way to personalize  /___\
   (MMM) the command line.  By Faux_Pseudo (MMM)

 
 
 

how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

Post by James T. Denni » Fri, 13 Oct 2000 04:00:00



> --(Once apon a time, in comp.unix.admin,)--
>            --(Peter Sundstrom said it like only they can.)--

>>#!/bin/ksh
>>#!/usr/local/bin/perl
>>#!/usr/local/bin/expect

>>or even something silly like

>>#!/bin/cat

> i had never thought about using a non shell for the she bang line
> that cat line was fun :)
> not that i will ever find a good reson to use it

 How about if you want to create a very quick and dirty version
 of nl (number lines):

#!/bin/cat -n

 .... That's it.  A one-liner.

 Incidentally there are many other one line filters that make sense.

 
 
 

how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

Post by Stefaan A Eecke » Fri, 13 Oct 2000 04:00:00




Quote:> shell scripts normally have to run under the same shell or at the very
> least, you have to specify say ksh shellscript...

> how do i create a shell script that will rewrap itself to the correct
> shell wrapper regardless of what shell the user runs it under?

> so even if the user is under sh, the shell will auto-sense and put a
> ksh wrapper on itself?

First line of the script should be hash-bang-interpreter:

#!/bin/ksh

This works with any interpreted script, not the only the
traditional shells:

#!/usr/local/bin/perl

and one can do nice tricks like:

#!/bin/sh
# the next line restarts using wish \

Take care,

--
Stefaan
--
Ninety-Ninety Rule of Project Schedules:
        The first ninety percent of the task takes ninety percent of
the time, and the last ten percent takes the other ninety percent.

 
 
 

how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

Post by Faux_Pseu » Sat, 14 Oct 2000 04:00:00


--(Once apon a time, in comp.unix.admin,)--
                --(James T. Dennis said it like only they can.)--
Quote:

> How about if you want to create a very quick and dirty version
> of nl (number lines):

>#!/bin/cat -n

> .... That's it.  A one-liner.

> Incidentally there are many other one line filters that make sense.

for things like that I have a tendacy to alias the comand
like on that one i would alias it as catn

kind of like if i need to us ls but my default ls is colorized
and that can cause some prob's with the escape sequances in one liners
so i aliased it to lc for ls colorless

--
 ._______.                               ._______.
 | <> <> |     GUI's are for slackers.   | <> <> |
  \-|o|-/   ibpconf.sh on freshmeat.net   \-|o|-/
   /___\   the easiest way to personalize  /___\
   (MMM) the command line.  By Faux_Pseudo (MMM)

 
 
 

1. how do i create a shell script that will rewrap itself to the correct shell wrap


   >shell scripts normally have to run under the same shell or at the
   >very least, you have to specify say ksh shellscript...
   >how do i create a shell script that will rewrap itself to the
   >correct shell wrapper regardless of what shell the user runs it
   >under?
   >so even if the user is under sh, the shell will auto-sense and put a
   >ksh wrapper on itself?
Find out where ksh is located on your system, and make the first line of
the script #! followed by the pathname, for example:
#!/bin/ksh
or
#!/usr/bin/ksh

Net-Tamer V 1.08X - Test Drive

2. linux-sun-jdk13 broke for me

3. how do i create a shell script that will rewrap itself to the correct shell wrapper regardless of what shell the user runs it under?

4. how to get eth0:0???

5. How to find other copies of same shell script running inside shell?

6. How to install LILO into a HD on Promise UDMA card?

7. c-shell script won't run from korn-shell / SETUID

8. Trying to install Linux on a 1.2 gig scsi

9. How to run shell script without login shell?

10. how to run your tcsh shell script in the new shell

11. ? Unix Shell Syntax to log out user from a shell script ?

12. Bourne shell script to determine users shell

13. handling SIGINT in shell scripts when executing another shell script.