Python: run service after hostapd

638 views Asked by At

I have been working on a project for a few weeks now and I encountered something (probably stupidly simple) I can't figure out!

import os
os.system("service hostapd start && hostapd /etc/hostapd/hostapd.conf")
os.system("service someservicethatIuse start")

When I start hostapd the script pauses because it enables an access point. I tried running it with xfce4-terminal --tab -e "hostapd /etc/hostapd/hostapd.conf" --tab -e "service someservicethatIuser start" but it doesn't seem to work :-/

(Language: Python 2.6)

2

There are 2 answers

2
Arman Ordookhani On

I don't know about hostapd, but usually it's enough to run service foo start to start a service and it does not block.

Anyways, you could run shell processes in prallel using sh & operator:

import os
os.system("service hostapd start && hostapd /etc/hostapd/hostapd.conf &")
os.system("service someservicethatIuse start")
0
Adam On

Use the -B option when you start hostapd, it should run it in the background

$~/hostapd -B /etc/hostapd/hostapd.conf