hashworks Jun 30 @ 2:07pm
[SOLVED] Start BASH script with sudo commands from steam
I'm currently trying to reboot my ubuntu system to windows using a steam shortcut.
I added the following script to my steam library:

#!/bin/bash

sudo grub-reboot "Windows" >> test 2>&1
sudo reboot >> test 2>&1

I also added grub-reboot and reboot to sudoers:
hashworks ALL = (root) NOPASSWD: /usr/sbin/grub-reboot
hashworks ALL = (root) NOPASSWD: /usr/sbin/reboot

Manually the script works just fine, also steam executes it as 'hashworks'.
However, the output of the file "test" is the following:
Sudo: no tty present and no askpass program specificed

Any idea?
Last edited by hashworks; Jul 1 @ 9:38am
Showing 1-4 of 4 comments
< >
Angry Mongoose Jun 30 @ 2:58pm 
oh i don't know... maybe you need to input the password for sudo to work?
spl Jun 30 @ 3:45pm 
You might try making your script launch a new terminal window with the commands you want so that you're able to enter your password.
I don't think it would be wise to set it up so that you don't have to enter your password, it would be a huge security risk.

However, to allow yourself to enter a password you could try something like this
(this is for a rxvt-unicode terminal, if you use something else you'll have to modify it)
#!/bin/bash

urxvt -e sudo grub-reboot "Windows" >> test 2>&1 && sudo reboot >> test 2>&1

that will start a terminal window and pass in the 2 commands to that new session to be run, which will allow you to enter your password.

If you need help modifying the command please tell us which terminal emulator you use
Last edited by spl; Jun 30 @ 8:05pm
hashworks Jun 30 @ 10:35pm 
Originally posted by Angry Mongoose:
oh i don't know... maybe you need to input the password for sudo to work?

Thats why I used the sudoers file. I need to reboot the pc to windows using Steam Streaming from somewhere in the house.

Originally posted by mearo (´・ω・`):
You might try making your script launch a new terminal window with the commands you want so that you're able to enter your password.
I don't think it would be wise to set it up so that you don't have to enter your password, it would be a huge security risk.

I'm ok with limiting the risk to reboot and grub-reboot, everything else needs a pw of course. I'm absolutly unable to enter a password from the couch with a xbox360 controller in my hands.

Originally posted by Angry Mongoose:
However, to allow yourself to enter a password you could try something like this
(this is for a rxvt-unicode terminal, if you use something else you'll have to modify it)
#!/bin/bash
urxvt -e sudo grub-reboot "Windows" >> test 2>&1 && sudo reboot >> test 2>&1

Mhm, I already had that idea with gnome-terminal,
which didn't work because of other stuff.

However, trying urxvt only grub-reboot worked - reboot requested a password.
Looking at /etc/sudoers showed me that the path in there was wrong (it's /sbin/reboot and not /usr/sbin/reboot). At the moment I tryed the script manually I already entered the sudo pw once leaving the sudoers file untestet (God dammit, yesterday-me...)

So I changed the path and now everything is working fine, without urxvt. Thanks for the help mearo!
Last edited by hashworks; Jun 30 @ 10:38pm
spl Jul 1 @ 12:22am 
glad you got it working
Showing 1-4 of 4 comments
< >
Per page: 15 30 50
Date Posted: Jun 30 @ 2:07pm
Posts: 4