Ubuntu – Run Python script on startup

pythonstartupUbuntu

Running on Ubuntu Karmic. I need to execute the following (updated) script at boot time

#!/bin/sh
# /etc/init.d/scripts
# Description: Starts Python scripts
# ————————————————–
#
### BEGIN INIT INFO
# Provides: Scripts
# Required-Start: $network $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start Python scripts to provide mapping services
### END INIT INFO

case $1 in
  start)
    # echo -n ¨Starting Mapping service: ¨
/usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False
;;
  stop)
# echo -n ¨Stoping Mapping service: ¨
/usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False
;;
  restart)
# echo -n ¨Retarting Mapping service: ¨
/usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False
;;
  *)
# echo ¨Usage: scripts {start|stop|restart}¨
exit 1
esac

Have placed it into /etc/init.d
Registered it with

sudo update-rc.d scripts defaults

But nothing happens on boot. I have tried looking in the logs but I can't find anything. Both scripts and liteserv.py are marked as executable.

As per Andy Smith's response, When I run:

/etc/init.d/scripts start  

I now get the program running correctly (after correcting the bad quotes).
However, it still does not run the program on bootup.

Best Answer

This is bizarre, but unless it is something that Stack Exchange is doing, I think the problem you are having is that you are using "fancy quotes" rather than "".

Whatever editor you are using may have replaced the standard quote character(Unicode U+0022) with stylized open and close quotes (U+201C and U+201D). sh doesn't like this very much. When I replace these stylized quotes with "normal quotes" your code works fine (with the small exception that I don't have the .py file it calls).

Related Question