| >> I'd like the same script to run on 2 different machines, Hp and
| >> Sun. The problem is that sh resides in different directories. Is
| >> there a way to have exec look in two places?
|
| >> P.S. No, I don't have write access to /usr/bin, or /bin
|
| >On every single machine I've seen sh is referable as /bin/sh. SUNOS
| >does this by having a symbolic link /bin -> /usr/bin, thus although sh
| >might actually reside in /usr/bin you can refer to it has /bin/sh. If
| >this isn't true then I would argue that your OS is very broke.
|
| There are more problems than just that. On HP /bin/sh is very simple.
| If you want to use the later-than-Unix-v7 feature getopts you have to
| use /bin/posix/sh instead. Sun and lots of other vendors have getopts
| in their /bin/sh. This problem will not be solved with a ':' on the
| first line.
|
I have the same problem between Sun and an Old Dec station running Ultrix
The default shell /bin/sh on ultrix is very very old and very brain dead
the solution is to use /bin/sh5 on this system. Something like your problem.
The following was my solution to make a shell script that works properly
on a sun work proper using sh5 under ultrix. Basically it looks for
a /bin/sh5 and if found switches shells automatically, Using a extra
flag to say if it is currently doing this.
Try this for your /bin/postix/sh problem or whatever shell you really want.
--------------8<-----------CUT HERE--------------8<---------------
#!/bin/sh
#
# A shell script that works on Sun's and Dec stations
#
# Check the type of shell that is running
[ "$1" = '-sh5' ] && shift
# Shell script starts here
# ...
--------------8<-----------CUT HERE--------------8<---------------
------------------------------------------------------------------------------
"[A computer is] like an Old Testament god,
with a lot of rules and no mercy." --- Joseph Campbell
------------------------------------------------------------------------------