PDA

View Full Version : Run task in background and close terminal



mogeb
May 30th, 2011, 03:50 PM
Hi all,
i have to something similar to this in a .bash script:

gksudo gedit
exit

After double-clicking on the .bash file and selecting "Run in terminal", a terminal opens, then gksudo asks for a password and gedit runs. I would like to hide the terminal at this point, so gedit would still run but the terminal window would be closed or hidden (so the exit wouldnt wait gedit to return).
Any way to do that?

Thank you

juancarlospaco
May 30th, 2011, 04:11 PM
nohup gksudo gedit

mogeb
May 30th, 2011, 04:19 PM
Thanks for your reply.. Already tried it, doesnt work. The terminal window stays.

juancarlospaco
May 30th, 2011, 04:27 PM
Do NOT "Run in terminal", just run it...

mogeb
May 30th, 2011, 04:38 PM
I have to run it in a terminal because there is interaction between the user and the console that happens before..

Is there anyway to know if the user clicked on "Run" or "Run in terminal"?

epicoder
May 30th, 2011, 08:35 PM
nohup command &The script will continue without waiting for command to finish, and if it exits before command does, command will stay running.
Nohup catches the hangup signal sent by a terminal/script when it exits. & runs the command in the background and allows the script to continue while the command is running.

mogeb
May 31st, 2011, 03:01 PM
Tried it too, but didn't work. I found another solution though. By adding the following lines:



gnome-terminal --command=$0
exit
That way, a terminal opens even if the user selects "Run"