Conex
Conex

Reputation: 822

/etc/init.d sh script

I'm new to python. I want to create controlled script executed from /etc/init.d command like /etc/init.d something start/stop/restart

Any advise appreciated.

Upvotes: 1

Views: 3009

Answers (3)

mjhm
mjhm

Reputation: 16695

If you're looking for a module for constructing daemons. I've used this: https://gist.github.com/slor/5946334

Upvotes: 1

udslk
udslk

Reputation: 529

Pardus initialization (http://www.pardus.org.tr/eng/projects/comar/SpeedingUpLinuxWithPardus.html) is based on python and in theory you can even start system with windows executable (through Wine of course). You can see a sample initialisation script there doing almost same thing with shell script but in a pythonic way.

Upvotes: 1

invert
invert

Reputation: 2076

See this post on how to write a script to place in your /etc/init.d directory. The only difference is you must change the hash-bang line to point to python, and not bash:

#!/usr/bin/python
def myfunc():
    print 'myfunct()'

if __name__ == '__main__':
    print 'running python script'
    myfunc()

And make the file executable

chmod +x myscript

Upvotes: 3

Related Questions