LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 06-27-2014, 02:39 PM   #1
lapishater276
Member
 
Registered: Jun 2014
Location: Narnia
Distribution: Crunchbang, Arch Linux ARM, Xubuntu
Posts: 43

Rep: Reputation: 0
can i write a shell script in /etc/init.d that will run a python script?


What i want to do is write a script to put in the /etc/init.d folder that will run. a python script. I cannot figure out how i would put pyhon commands in the skeleton provided. If someone could write a script that would work, it would be much appreciated
 
Old 06-27-2014, 03:23 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
The skeleton provide is a shell script but has key elements that need to be there understood by the startup routines. Your python script would not be.

However, you could simply tell the start, stop, status etc... sections of that skeleton to call your python script(s) (with the appropriate flags if any).

You can get the hplip init script online to find an example of one that contains calls to .py files. The Postgresql init script calls the pg_ctl binary so that would be an example of that. I don't have Debian but I suspect if you look through existing files you'll find where they are calling other things such as python, perl, binaries etc....

Note that /etc/init.d is just where the base script lives - you have to make sure you put links in the run level directories (e.g. /etc/rc2.d, /etc/rc3.d etc...).

Note that just like with cron jobs you have to make sure all environment variables you need are in the script itself or sourced by it as it will NOT automatically have the same environment variables it would inherit from a logged in shell session.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help calling a shell script inside a python script WyoChuck Linux - Newbie 4 05-28-2012 09:39 PM
Need to write a shell script to run in cygwin spart1985 Linux - Newbie 2 02-21-2012 12:54 AM
How to close open ports using a python script or a shell script in python ?? apanimesh061 Programming 3 11-20-2011 12:31 AM
[SOLVED] write a shell script so that it can run as service/daemon deostroll Programming 10 03-08-2010 10:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 01:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration