LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Desktop Launcher of shell-script in gnome-terminal (https://www.linuxquestions.org/questions/linux-newbie-8/desktop-launcher-of-shell-script-in-gnome-terminal-735274/)

skipidar 06-24-2009 07:57 AM

Desktop Launcher of shell-script in gnome-terminal
 
Hello everybody,

my problem is quite simple:

i want to have a launcher of a command: "grub-reboot 4"
on my desktop.





But this little problem brought me into hell.


1. First i tried to create a launcher with

"gnome-terminal -e 'grub-reboot 4'"

Error: nothing happens....


2. Then is created a shellscript

#! /bin/sh"
grub-reboot 4

and made it executable with "chmod a+x script.sh"
gave permissions with "chmod 777"

Tried to start it from terminal, it works with
"sh script.sh"
"./script.sh"
but only with root right, otherwise it tells that command doesn's exist!


2.1 Tried to launch the shell-script so that it's output appears in
terminal.

"/bin/sh /home..../script.sh "
"gnome-terminal -e /home..../script.sh"
"gnome-terminal -x /home..../script.sh"

Didn't produce any output, or noncence like


which message don't make any sence for me,
because it appears, when the scipt doesn't exists, or i dont have the rights to execute the script or.....


2.2 When i found out, that this message:
"There was an error creating the child process for this terminal" appears, when i have no rights to execute a script,
i tried to create a Launcher with

"gksudo /home..../script.sh"

Which started the Terminal, as i wanted,
showed the script output,

AND
appended something like
"scanning for DEVICES, i will need a while for that , lalala"

2.3

At least i created a Launcher with

"sudo /home..../script.sh"

which was the correct way, and gave me my output in terminal.






Conclusion:

Job: execute root command in terminal, showin it's output in terminal


Solution:
1. create a shell script "scriptname.sh", which includes #! /bin/sh" in the row 1,
and all commands then, which you want to execute

2. make file executable with command "chmod a+x scriptname.sh"
3. set permissions of this script with "chmod 777 scriptname.sh"

4. create a launcher, pointing directrly to the script:

"sudo /home..../scriptname.sh" if root right are required for execution
"/home..../scriptname.sh" else.






Question to the Profis:

Is there a way to get better Error output in Linux?
If the System would clearly point out, that the problem is in the
missing scriptfile or missing rights,
this could be solved in 2 min, i needed 3 hours for that,

Linux will never rule the world, until the usability and clear user<->pc communication wont be present in it.

Agrouf 06-24-2009 09:27 AM

When you execute a command with gnome-terminal -e, all the output of that command goes to the newly created terminal. this is the point in launching something with gnome-terminal. Once the command has terminated, the gnome-terminal is closed. In your case, the error is displayed in gnome-terminal and the gnome-terminal is immediately terminated.
This is exactly what I expect from gnome-terminal. If you want to see the errors in your script, you should either redirect the output to somewhere or not launch it in a specifically created gnome-terminal or you should make sure your script does not stop after an error. The point of using gnome-terminal to launch your script is that all the output goes to that terminal.

Anyway, I understand how frustrating something must be when you don't understand it. I just spent 3 days trying to figure out why my damn SQL server didn't open the damn port on my Windows machine. It turns out the error was burried in the event dialog in the administrative stuff of system settings. Very very frustrating when you don't know where to look for an error and the system does not do what you expect it to do. I guess Windows will never rule the world either.


All times are GMT -5. The time now is 01:00 AM.