I have my Debian virtual machine
set to automatically login, and I want to make it so that, when the auto-login occurs, a terminal will open and run the command
python /home/pymodbus/examples/common/synchronous_client.py
The output from the python script occurs within the terminal, which is why I would like to open it in the first place. I have already done a lot of research, and have tried many things, including put this command in the /etc/rc.local
file, but this did not appear to do anything.
Additionally, I tried this
gnome-terminal -e "python /home/pymodbus/examples/common/synchronous_client.py"
But this did not start the terminal upon login as I thought it would.
Does anyone have some insight into how to accomplish this? I am very new to Linux, and trying to figure out which packages and tools I need has been a very confusing experience!
So I was able to figure out how to do this, and I wanted to share my findings here. Here're the steps I took:
.bashrc
file in /home/etc/
and put my command at the very end, after all the prewritten code (sudo python /home/usr/pymodbus/examples/common/synchronous_client.py
). Make sure you have sudo in your command.To get the terminal to launch at startup, I created a desktop file in ~/.config/autostart
(if you don't have the autostart folder, you can just create one).
In the autostart folder, I created a .desktop
file called gnome-terminal.desktop
and populated it as follows:
[Desktop Entry]
Type=Application
Exec=gnome-terminal
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_NG]=Terminal
Name=Terminal
Comment[en_NG]=Start Terminal On Startup
Comment=Start Terminal On Startup
Finally, to bypass the need to type the sudo
password when I wanted to run the script, I ran the command sudo visudo
and put the following line at the very end of the file:
<username> ALL=(ALL) NOPASSWD:ALL
I hope this helps anyone that might be attempting to do something similar to me!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments