[ale] Question for perl gurus
Christopher Fowler
cfowler at outpostsentinel.com
Wed Mar 5 12:18:59 EST 2003
I need to convert this script to perl to solve a problem that
I do not believe bash solves.
#!/bin/sh
for i in /home/*
do
U=`basename $i`
if [ -f ${i}/rc ]
then
echo "Starting RC script for: "${U}
su - ${U} -c "./rc $*"
fi
done
What this simple script does is live in /etc/rc.d/init.d and looks
at every users home directory for a file called ~/rc. If it sees that
file then it executes it as the user. That file can look like this
#!/bin/sh
# ~/rc
case $1 in
start)
# Do something
;;
stop)
# Kill something
;;
*)
echo "user [start|stop]
exit 1
;; # Unreachable
easc
In the first script I want to make sure that
the user rc script's execution will timeout after 2 minutes.
If so we'll allow it to stay in the background and continue
on to the next user. After we (parent) exits, it is still possible
for a user rc script to be running, init will reap it upon death.
I C I would use fork() and timeout on waitpid(). Its been a while
since I've done perl so I'm drawing a very big blank. Maybe there is a
bash solution to this?
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list