Quantcast
Viewing all articles
Browse latest Browse all 5

systemd service, data from stdout

I have a python script that currently gets data from lower level bash and c programs via stdout using subprocess. The heart of it looks like this:

 def execute(self):             self.P = subprocess.Popen(["bash", "PacketMonitor.sh", self.host],                             stdout=subprocess.PIPE,                             stderr=subprocess.STDOUT,                             universal_newlines=True)              for stdout_line in iter(self.P.stdout.readline, ""):                     yield stdout_line             self.P.stdout.close()             return_code=self.P.wait() 

This all works just fine when I execute the code from the command line and I can see the values of my packets being printed to a log file.

However, when I wrap this all up in a systemd service and run the service with systemctl start, I never get any values out of the stdout.

This is my service file definition:

[Unit] Description=batch listener service After=network.target StartLimitIntervalSec=0  [Service] Type=simple Restart=always RestartSec=1 User=pi ExecStart=/usr/bin/python2 /home/pi/BatchListener/BatchService.py  [Install] WantedBy=multi-user.target 

I am guessing there is something fundamental about how the systemd services are run that I do not understand; or maybe something fundamental about subprocess that I do not understand.

The post systemd service, data from stdout appeared first on 100% Private Proxies - Fast, Anonymous, Quality, Unlimited USA Private Proxy!.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>