Use of Perl in Unix startup / shutdown scripts

L

Larry

On the Solaris system I'm using, you can specify a set of sequence of
scripts that will run at the time the system is booted or shut down. I
have replaced a pair (startup / shutdown) of scripts that was
originally written in Korn shell with an improved version in Perl. The
Perl versions have been working fine, but lately I am hearing vague
grumblings from Sys Admins here about the use of Perl scripts for
system startup / shutdown sequences. The Admins are claiming that it
is bad practice to write them in any language but shell. Does anyone
here have any info on this issue?
 
U

usenet

Larry said:
On the Solaris system I'm using, you can specify a set of sequence of
scripts that will run at the time the system is booted or shut down. I
have replaced a pair (startup / shutdown) of scripts that was
originally written in Korn shell with an improved version in Perl. The
Perl versions have been working fine, but lately I am hearing vague
grumblings from Sys Admins here about the use of Perl scripts for
system startup / shutdown sequences. The Admins are claiming that it
is bad practice to write them in any language but shell. Does anyone
here have any info on this issue?
There could be issues if the perl interpreter isn't available on the
root filesystem. It certainly won't be there by default so, if things
get really screwed up you might find that you can't run the scripts
when trying to repair a damaged system.
 
C

Calle Dybedahl

usenet" == usenet said:
There could be issues if the perl interpreter isn't available on the
root filesystem. It certainly won't be there by default so

On Solaris version 8 and up it will, unless the person who installed
the machine went to significant effort to remove it (in which case the
setup is no longer supported by Sun). The only thing the original
poster has to do is to make sure to use the Perl installed in
/usr/perl5 rather than any version installed locally.

And if you're now tempted to say "But what if /usr is too busted to be
mountable?", then the answer (on Solaris) is that if so the system
won't boot far enough for startup scripts to be an issue. /lib and
/bin are symlinks to /usr/lib and /usr/bin, and while there are some
binaries under /sbin that can run without /usr/lib, fsck is not one of them.
 
L

Larry

I am not really concerned about the "unmountable perl" issue, because
if the Perl startup scripts start up applications on other filesystems
anyway, so if Perl is unmountable, then those other applications are
also probably unmountable. In any event, Sys Admins did not mention
the "unmountable disk" issue as a reason. Are there any other reasons
to prefer Korn shell over Perl for startup scripts?
 
B

Big and Blue

Larry said:
Are there any other reasons
to prefer Korn shell over Perl for startup scripts?

Simplicity, although I'd use simple Bourne-shell (sh) rather than ksh
anyway. The startup scripts are usually simple shell scripts. Of course,
since they are supposed to stop/start a service there is nothing to stop
you writing a simple sh script for init.d which just calls a
service-specific command with relevant options (satisfying your admins) and
making this service-specific command be a perl command.

If they are so worried about startup cripts you could also ask them
what they have done about the daft pratcice that Sun have of *hard* linking
from rc?.d into init.d, which makes it possible, according to how you edit
files, to end up with different scripts in different state dirs if you
aren't careful. e.g.: you have edited a startup file and now have the
updated version you wish to install under your HOME as my-edited-starter:

cd /etc/init.d
mv a-astarter x-starter
cp ~me/my-edited-starter a-starter

seems a reasonable way to update a file while retaining a copy of the
original, and on Linux (etc.) will work as they use symbolic links. On Sun
nothing happens, as the rc?.d versions are still all hard-linked to the
original.
 
L

Larry

I doubt writing a shell script that calls a Perl script would satisfy
them. I understand the simplicity ideal, but simplicity can't override
every other goal. The reason they are not simple is that sometimes
during the shutdown, the application I'm trying to shut down could
hang. If the shutdown script hangs, so does the whole shutdown
sequence. So I built in a timeout feature to my Perl script which lets
it exit if the application won't shut down. There are other fancy
things my script does, such as email me if there's a problem.
 
A

axel

Larry said:
I am not really concerned about the "unmountable perl" issue, because
if the Perl startup scripts start up applications on other filesystems
anyway, so if Perl is unmountable, then those other applications are
also probably unmountable. In any event, Sys Admins did not mention
the "unmountable disk" issue as a reason. Are there any other reasons
to prefer Korn shell over Perl for startup scripts?

Portability, if you use Bourne shell rather than the Korn shell. But
then it sounds as if that would not be an issue in your situation.

Axel
 
J

Joe Smith

Larry said:
On the Solaris system I'm using, you can specify a set of sequence of
scripts that will run at the time the system is booted or shut down. I
have replaced a pair (startup / shutdown) of scripts that was
originally written in Korn shell with an improved version in Perl. The
Perl versions have been working fine, but lately I am hearing vague
grumblings from Sys Admins here about the use of Perl scripts for
system startup / shutdown sequences. The Admins are claiming that it
is bad practice to write them in any language but shell.

It is horrible practice to write startup/shutdown scripts using
/usr/local/bin/perl. It is perfectly fine to use /usr/perl5/bin/perl
on Solaris-8 or later since Sun provides that version of perl for
that very purpose.

I don't know if it would help, but you could mention that Linux
uses Python in its startup scripts; yet another language that is
not sh/bash/ksh/...

-Joe
 
L

Lawrence D¹Oliveiro

Larry said:
The Perl versions have been working fine, but lately I am hearing vague
grumblings from Sys Admins here about the use of Perl scripts for
system startup / shutdown sequences. The Admins are claiming that it
is bad practice to write them in any language but shell.

I have done startup/shutdown programs in Perl as well as compiled C++.
Do your admins have anything to say about the use of C++?

One set of Perl startup/shutdown scripts I did was for managing the
!@#$% flexlm licence system for MATLAB. We were serving a couple of
different licences from the same machine, but the standard shutdown
procedure for each one would kill *all* instances of both
licence-serving processes. So I wrote my own slightly more sophisticated
alternative. It was the kind of thing that seemed more natural in Perl,
so what's what I used.
 
S

samwyse

Larry said:
In any event, Sys Admins did not mention
the "unmountable disk" issue as a reason. Are there any other reasons
to prefer Korn shell over Perl for startup scripts?

I'd suggest asking your Sys Admins for their reasons, then.

BTW, I have written many shell wrappers for startup/shutdown programs
that were provided by a vendor, althought it's usually because (as one
example) the vendor for some insane reason wants 'start' and 'shutdown'
as parameters instead of 'start' and 'stop'. If your admins continue to
press the issue without providing good reasons, then by all means give
them something like this:

#!/bin/sh
APPHOME=/opt/vendor/application
case $1
start) $APPHOME/bin/init.pl start ;;
stop) $APPHOME/bin/init.pl stop ;;
esac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top