I have written a python script which contains a menu in an infinite loop. My goal is start the script in terminal when a user logs in and start interacting with it. I have created a launcher.sh file which will execute on startup and registered it in crontab. However, when system reboots it gives following error:
1: START
2: POWEROFF
Please make a choice: Traceback (most recent call last):
File "menu.py", line 27, in <module>
main()
File "menu.py", line 16, in main
choice = input ("Please make a choice: ")
EOFError: EOF when reading a line
Here is my script:
#!/usr/bin/python3
def main():
while True:
print("1: START")
print("2: POWEROFF")
choice = input ("Please make a choice: ")
print(choice)
... other operations
Here is my launcher.sh file:
#!/bin/sh
# launcher.sh
cd /home/rao/Desktop/project
sudo python3 menu.py
cd /
And crontab line:
@reboot sh /home/rao/Desktop/project/launcher.sh >> /home/rao/Desktop/project/logs/status.log 2>&1
Where am I going wrong?
It worked when I put the following command in Startup Applications
x-terminal-emulator -e "python3 /path-to-script/menu.py"