I have a python bot that I launch in command line and askes me a login to start working.
To skip this step, I add a pipe to directly insert the login in the command as the following and it works :
printf "login" | python_module-py
Now, I want to schedule the bot's launch to don't have to launch it by myself and avoid the bot needing my computer always on.
So I bought a Debian VPS and tried to create a systemd service. I put the command in a shell. Here is my service : (assuming my script is in /home/user and I have all the rights rwx)
[Unit]
Description=Description
After=network.target
[Service]
Type=simple
User=user
Group=group
WorkingDirectory=/home/user
ExecStart=./script.sh
[Install]
WantedBy=multi-user.target
I tried to start it but it failed because of this error :
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
I'm almost sure that's because the login is not passed through the pipe and I'm wondering why.
Please, pardon me in advance for my english.
[ALSO TESTED]
Keep the command in the service using /bin/sh -c
also giving the same error :
ExecStart=/bin/sh -c '/usr/bin/printf "login" | /usr/bin/python3.7 -m python_module'
I solved the problem.
In my case, I had to use the xargs command to ensure that the text pasted in the pipe is really pasted.
printf "login" | xargs python_module-py