NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
Quikdav
Sep 30, 2011Aspirant
Running PERL script in background
Hi all I would like to run a PERL script as a background task on my NV+. This script will read a monitoring device connected on the USB port to monitor my electricity usage to write the result into...
Quikdav
Nov 10, 2011Aspirant
Hi all
I progressed in my research to run a PERL script as a daemon. So I created a script in inti.d and I'm testing it. It seems to be very simple but it doesn't works !!!
When I run the script below, I have no error and I have message telling the script is running. The pid file is created but when I look for running daemons, I have nothing regarding it!!!
I just want to run a Perl script with a parameter. So maybe I don't use the good value with start-stop-daemon arguments, I don't know !!!
When I try my script, it work fine (/usr/bin/perl -I"/c/webroot/CurrentCostPerl/lib" /c/webroot/CurrentCostPerl/bin/current-cost-reader /dev/ttyUSB0)
I tried to remove the -I argument for the PERL. I used the pragma "use lib" directly in my code. It has no effect. My daemon is not launching !!
Does anyone have an idea. I think it must be a subtle but I tried so many cases !!!
Thanks
David
I progressed in my research to run a PERL script as a daemon. So I created a script in inti.d and I'm testing it. It seems to be very simple but it doesn't works !!!
When I run the script below, I have no error and I have message telling the script is running. The pid file is created but when I look for running daemons, I have nothing regarding it!!!
I just want to run a Perl script with a parameter. So maybe I don't use the good value with start-stop-daemon arguments, I don't know !!!
When I try my script, it work fine (/usr/bin/perl -I"/c/webroot/CurrentCostPerl/lib" /c/webroot/CurrentCostPerl/bin/current-cost-reader /dev/ttyUSB0)
I tried to remove the -I argument for the PERL. I used the pragma "use lib" directly in my code. It has no effect. My daemon is not launching !!
Does anyone have an idea. I think it must be a subtle but I tried so many cases !!!
#!/bin/sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="Script PERL de monitoring du CurrentCost"
NAME=CurrentCostPerlMonitoring
DAEMON="/c/webroot/CurrentCostPerl/bin/current-cost-reader"
DAEMON_ARGS="/dev/ttyUSB0"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON_OPT='-I"/c/webroot/CurrentCostPerl/lib"'
test -f $DAEMON || exit 0
set -e
#
# Function that starts the daemon/service
#
d_start()
{
start-stop-daemon --start --quiet --background --verbose --make-pidfile --pidfile $PIDFILE --exec /usr/bin/perl -- $DAEMON_OPT --startas $DAEMON $DAEMON_ARGS ||return 1
}
#
# Function that stops the daemon/service.
#
d_stop()
{
start-stop-daemon --oknodo --stop --pidfile $PIDFILE --name skynet_perl --retry=TERM/30/KILL/5
}
case "$1" in
start)
echo -n "Starting $DESC: "
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: "
d_stop
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Thanks
David
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!