I want to make a script and add this to a shortcut launcher...
When i double click the icon, it will popup a terminal window (done)
In the terminal, it will ask for root password at first and then do some stuff with root privilege (I want to make it as a function).
After that, at the end of the script, it will close the window like "press any key to close window" (I can do it)
#!/bin/sh
touchpad(){
whoami
}
sudo -S touchpad # but it return error "command not found"
How to run a function as root user or is there another way to accomplish this?
EDIT :
I have tried this
#!/bin/bash
sudo ./main2.sh #this did not work when I made it as a launcher
exit
This is my current code (after googling):
#!/bin/bash
gksudo -m "Input Password" clear
sudo whoami
#sudo bla bla bla
read -n 1 -p "Press any key to close window"
This is what I want, but got an error when I type the wrong password for 3 times. How to force quit the main window if gksudo fail??