Sample Header Ad - 728x90

cannot access USB device from a program started with systemd

0 votes
4 answers
1546 views
I have the following script to send SMS messages with a GSM usb modem: #!/bin/bash env > /home/hans/systemenv.txt #touch /home/homeassistant/pipo2.txt read count /dev/ttyUSB0 chat TIMEOUT 1 "" "AT+CMGS=\"0123456789\"" "OK" > /dev/ttyUSB0 chat TIMEOUT 1 "" "$1" "OK" > /dev/ttyUSB0 chat TIMEOUT 1 "" "^Z" "OK" > /dev/ttyUSB0 #sleep 2 #chat TIMEOUT 1 "" "AT+CMGS=\"0987654321\"" "OK" > /dev/ttyUSB0 #chat TIMEOUT 1 "" "$1" "OK" > /dev/ttyUSB0 #chat TIMEOUT 1 "" "^Z" "OK" > /dev/ttyUSB0 let 'count++' echo $count > /home/homeassistant/.homeassistant/smsCounter.txt The script works fine when called from the command line, but when it is called from any program that was started with systemd, the script actually runs, but the chat commands do not get executed. Running sudo journalctl -f -xe, shows the following when the script is called from a program running in a systemd service: Oct 08 13:37:37 homeassistant chat: Can't get terminal parameters: Inappropriate ioctl for device Oct 08 13:37:37 homeassistant chat: Can't get terminal parameters: Inappropriate ioctl for device Oct 08 13:37:37 homeassistant chat: Can't get terminal parameters: Inappropriate ioctl for device Oct 08 13:37:37 homeassistant chat: Can't get terminal parameters: Inappropriate ioctl for device In this case, the script was called from a program called home assistant. Home assistant was started from a systemd.service script. If I start home assistant from the terminal, as the same user that the systemd.service was running as, the above do not show and the sms gets sent. Calling the same script from any other program that was started with systemctl results in the same error.
Asked by user2879815 (1 rep)
Oct 8, 2017, 01:44 PM
Last activity: Sep 11, 2019, 01:23 PM