Desktop file can't run script in terminal












2















I want to make a button on my lxpanel to launch a program that prints out Hello World! in a pop-up lxterminal, so I use the technique that I successfully implemented before in Debian 7, which is:





  1. gedit /bin/hello.sh (contents below):



    #!/bin/bash
    echo 'Hello World!';



  2. gedit /usr/share/applications/hello1.desktop (below):



    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Hello1
    Comment=Test the terminal running a command inside it
    Exec=lxterminal -e "/bin/hello.sh"
    StartupNotify=true
    Icon=utilities-terminal
    Terminal=true
    Categories=Utility;



  3. Last I chown and chmod both of the above files as below:



    -rwxr-xr-x 1 a adm 230  1月  1 13:02 /usr/share/applications/hello1.desktop*
    -rwxr-xr-x 1 a adm 240 1月 1 12:57 /usr/share/applications/hello1.desktop~*
    -rwxr-xr-x 1 a adm 194 1月 1 12:04 /usr/share/applications/hello.desktop*
    -rwxr-xr-x 1 a adm 195 1月 1 12:03 /usr/share/applications/hello.desktop~*
    -rwxrwxr-x 1 a adm 87 1月 1 12:35 /usr/share/applications//bin/hello.sh*
    -rwxrwxr-x 1 a a 87 1月 1 12:25 /usr/share/applications//bin/hello.sh~*
    -rwxrwxr-x 1 a adm 134 12月 13 09:56 /usr/share/applications//bin/hello_world.sh*



Unfortunately no matter what I do, the hello1.desktop file only can open a blank lxterminal, and there is no output.



I am running Lubuntu 14.04 and have followed the following tutorials to link a desktop file to a *.sh script program:




  • Create a .desktop file that opens and execute a command in a terminal

  • Starting a script in a Desktop icon

  • http://ubuntuforums.org/showthread.php?t=2194284

  • http://lkubaski.wordpress.com/2012/06/29/adding-lxde-start-menu-and-desktop-shortcuts/

  • http://forum.lxde.org/viewtopic.php?f=8&t=31647

  • http://forum.lxde.org/viewtopic.php?f=26&t=31373

  • https://bugs.launchpad.net/ubuntu/+source/lubuntu-default-settings/+bug/975152


I also made the following variations to hello1.desktop:




  • line 10 (last line) - I also tried it without a semi-colon.

  • line 9 (the "Terminal" line) - tried "false"


  • line 6 (the "Exec" line) - tried these:



    Exec=sh /bin/hello.sh;
    Exec=lxterminal -e “/bin/hello.sh”
    Exec=/bin/hello.sh
    Exec=sh -c /bin/hello.sh
    Exec=lxterminal -x sh -c 'echo hello'
    Exec=sh -c 'gnome-terminal echo hello'
    Exec=sh -c 'echo hello'
    Exec=sh /bin/hello.sh
    Exec=sh -c /bin/hello.sh



But in the end all are the same (except when Terminal=false on line 9 there is no terminal, obviously).



I can see hello1 under System -> Accessories, but when I click on it still just a blank screen pops out. In debian 7.5 LXDE wheezy this is really easy to do successfully, but what is wrong in Lubuntu 14.04 to make it so much more difficult?



Andrew










share|improve this question




















  • 3





    Skip the HTML tags and format it as code (select and press press Ctrl-K). At the moment it is hard to say what's in your files and what's not.

    – muru
    Jan 1 '15 at 10:43











  • @muru I fixed it. Hopefully I didn't break anything.

    – wjandrea
    8 hours ago











  • How did you get that ls output? Why are there files like /usr/share/applications//bin/hello.sh? Why are you adding system-level files to test this instead of user-level (i.e. in ~/bin and ~/.local/share/applications). How are you using gedit without sudo to edit system-level files? Also note you have curly quotes in one of those exec lines: Exec=lxterminal -e “/bin/hello.sh” (I know this is an old question - just voicing my concerns in case of similar questions in the future.)

    – wjandrea
    8 hours ago


















2















I want to make a button on my lxpanel to launch a program that prints out Hello World! in a pop-up lxterminal, so I use the technique that I successfully implemented before in Debian 7, which is:





  1. gedit /bin/hello.sh (contents below):



    #!/bin/bash
    echo 'Hello World!';



  2. gedit /usr/share/applications/hello1.desktop (below):



    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Hello1
    Comment=Test the terminal running a command inside it
    Exec=lxterminal -e "/bin/hello.sh"
    StartupNotify=true
    Icon=utilities-terminal
    Terminal=true
    Categories=Utility;



  3. Last I chown and chmod both of the above files as below:



    -rwxr-xr-x 1 a adm 230  1月  1 13:02 /usr/share/applications/hello1.desktop*
    -rwxr-xr-x 1 a adm 240 1月 1 12:57 /usr/share/applications/hello1.desktop~*
    -rwxr-xr-x 1 a adm 194 1月 1 12:04 /usr/share/applications/hello.desktop*
    -rwxr-xr-x 1 a adm 195 1月 1 12:03 /usr/share/applications/hello.desktop~*
    -rwxrwxr-x 1 a adm 87 1月 1 12:35 /usr/share/applications//bin/hello.sh*
    -rwxrwxr-x 1 a a 87 1月 1 12:25 /usr/share/applications//bin/hello.sh~*
    -rwxrwxr-x 1 a adm 134 12月 13 09:56 /usr/share/applications//bin/hello_world.sh*



Unfortunately no matter what I do, the hello1.desktop file only can open a blank lxterminal, and there is no output.



I am running Lubuntu 14.04 and have followed the following tutorials to link a desktop file to a *.sh script program:




  • Create a .desktop file that opens and execute a command in a terminal

  • Starting a script in a Desktop icon

  • http://ubuntuforums.org/showthread.php?t=2194284

  • http://lkubaski.wordpress.com/2012/06/29/adding-lxde-start-menu-and-desktop-shortcuts/

  • http://forum.lxde.org/viewtopic.php?f=8&t=31647

  • http://forum.lxde.org/viewtopic.php?f=26&t=31373

  • https://bugs.launchpad.net/ubuntu/+source/lubuntu-default-settings/+bug/975152


I also made the following variations to hello1.desktop:




  • line 10 (last line) - I also tried it without a semi-colon.

  • line 9 (the "Terminal" line) - tried "false"


  • line 6 (the "Exec" line) - tried these:



    Exec=sh /bin/hello.sh;
    Exec=lxterminal -e “/bin/hello.sh”
    Exec=/bin/hello.sh
    Exec=sh -c /bin/hello.sh
    Exec=lxterminal -x sh -c 'echo hello'
    Exec=sh -c 'gnome-terminal echo hello'
    Exec=sh -c 'echo hello'
    Exec=sh /bin/hello.sh
    Exec=sh -c /bin/hello.sh



But in the end all are the same (except when Terminal=false on line 9 there is no terminal, obviously).



I can see hello1 under System -> Accessories, but when I click on it still just a blank screen pops out. In debian 7.5 LXDE wheezy this is really easy to do successfully, but what is wrong in Lubuntu 14.04 to make it so much more difficult?



Andrew










share|improve this question




















  • 3





    Skip the HTML tags and format it as code (select and press press Ctrl-K). At the moment it is hard to say what's in your files and what's not.

    – muru
    Jan 1 '15 at 10:43











  • @muru I fixed it. Hopefully I didn't break anything.

    – wjandrea
    8 hours ago











  • How did you get that ls output? Why are there files like /usr/share/applications//bin/hello.sh? Why are you adding system-level files to test this instead of user-level (i.e. in ~/bin and ~/.local/share/applications). How are you using gedit without sudo to edit system-level files? Also note you have curly quotes in one of those exec lines: Exec=lxterminal -e “/bin/hello.sh” (I know this is an old question - just voicing my concerns in case of similar questions in the future.)

    – wjandrea
    8 hours ago
















2












2








2








I want to make a button on my lxpanel to launch a program that prints out Hello World! in a pop-up lxterminal, so I use the technique that I successfully implemented before in Debian 7, which is:





  1. gedit /bin/hello.sh (contents below):



    #!/bin/bash
    echo 'Hello World!';



  2. gedit /usr/share/applications/hello1.desktop (below):



    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Hello1
    Comment=Test the terminal running a command inside it
    Exec=lxterminal -e "/bin/hello.sh"
    StartupNotify=true
    Icon=utilities-terminal
    Terminal=true
    Categories=Utility;



  3. Last I chown and chmod both of the above files as below:



    -rwxr-xr-x 1 a adm 230  1月  1 13:02 /usr/share/applications/hello1.desktop*
    -rwxr-xr-x 1 a adm 240 1月 1 12:57 /usr/share/applications/hello1.desktop~*
    -rwxr-xr-x 1 a adm 194 1月 1 12:04 /usr/share/applications/hello.desktop*
    -rwxr-xr-x 1 a adm 195 1月 1 12:03 /usr/share/applications/hello.desktop~*
    -rwxrwxr-x 1 a adm 87 1月 1 12:35 /usr/share/applications//bin/hello.sh*
    -rwxrwxr-x 1 a a 87 1月 1 12:25 /usr/share/applications//bin/hello.sh~*
    -rwxrwxr-x 1 a adm 134 12月 13 09:56 /usr/share/applications//bin/hello_world.sh*



Unfortunately no matter what I do, the hello1.desktop file only can open a blank lxterminal, and there is no output.



I am running Lubuntu 14.04 and have followed the following tutorials to link a desktop file to a *.sh script program:




  • Create a .desktop file that opens and execute a command in a terminal

  • Starting a script in a Desktop icon

  • http://ubuntuforums.org/showthread.php?t=2194284

  • http://lkubaski.wordpress.com/2012/06/29/adding-lxde-start-menu-and-desktop-shortcuts/

  • http://forum.lxde.org/viewtopic.php?f=8&t=31647

  • http://forum.lxde.org/viewtopic.php?f=26&t=31373

  • https://bugs.launchpad.net/ubuntu/+source/lubuntu-default-settings/+bug/975152


I also made the following variations to hello1.desktop:




  • line 10 (last line) - I also tried it without a semi-colon.

  • line 9 (the "Terminal" line) - tried "false"


  • line 6 (the "Exec" line) - tried these:



    Exec=sh /bin/hello.sh;
    Exec=lxterminal -e “/bin/hello.sh”
    Exec=/bin/hello.sh
    Exec=sh -c /bin/hello.sh
    Exec=lxterminal -x sh -c 'echo hello'
    Exec=sh -c 'gnome-terminal echo hello'
    Exec=sh -c 'echo hello'
    Exec=sh /bin/hello.sh
    Exec=sh -c /bin/hello.sh



But in the end all are the same (except when Terminal=false on line 9 there is no terminal, obviously).



I can see hello1 under System -> Accessories, but when I click on it still just a blank screen pops out. In debian 7.5 LXDE wheezy this is really easy to do successfully, but what is wrong in Lubuntu 14.04 to make it so much more difficult?



Andrew










share|improve this question
















I want to make a button on my lxpanel to launch a program that prints out Hello World! in a pop-up lxterminal, so I use the technique that I successfully implemented before in Debian 7, which is:





  1. gedit /bin/hello.sh (contents below):



    #!/bin/bash
    echo 'Hello World!';



  2. gedit /usr/share/applications/hello1.desktop (below):



    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Hello1
    Comment=Test the terminal running a command inside it
    Exec=lxterminal -e "/bin/hello.sh"
    StartupNotify=true
    Icon=utilities-terminal
    Terminal=true
    Categories=Utility;



  3. Last I chown and chmod both of the above files as below:



    -rwxr-xr-x 1 a adm 230  1月  1 13:02 /usr/share/applications/hello1.desktop*
    -rwxr-xr-x 1 a adm 240 1月 1 12:57 /usr/share/applications/hello1.desktop~*
    -rwxr-xr-x 1 a adm 194 1月 1 12:04 /usr/share/applications/hello.desktop*
    -rwxr-xr-x 1 a adm 195 1月 1 12:03 /usr/share/applications/hello.desktop~*
    -rwxrwxr-x 1 a adm 87 1月 1 12:35 /usr/share/applications//bin/hello.sh*
    -rwxrwxr-x 1 a a 87 1月 1 12:25 /usr/share/applications//bin/hello.sh~*
    -rwxrwxr-x 1 a adm 134 12月 13 09:56 /usr/share/applications//bin/hello_world.sh*



Unfortunately no matter what I do, the hello1.desktop file only can open a blank lxterminal, and there is no output.



I am running Lubuntu 14.04 and have followed the following tutorials to link a desktop file to a *.sh script program:




  • Create a .desktop file that opens and execute a command in a terminal

  • Starting a script in a Desktop icon

  • http://ubuntuforums.org/showthread.php?t=2194284

  • http://lkubaski.wordpress.com/2012/06/29/adding-lxde-start-menu-and-desktop-shortcuts/

  • http://forum.lxde.org/viewtopic.php?f=8&t=31647

  • http://forum.lxde.org/viewtopic.php?f=26&t=31373

  • https://bugs.launchpad.net/ubuntu/+source/lubuntu-default-settings/+bug/975152


I also made the following variations to hello1.desktop:




  • line 10 (last line) - I also tried it without a semi-colon.

  • line 9 (the "Terminal" line) - tried "false"


  • line 6 (the "Exec" line) - tried these:



    Exec=sh /bin/hello.sh;
    Exec=lxterminal -e “/bin/hello.sh”
    Exec=/bin/hello.sh
    Exec=sh -c /bin/hello.sh
    Exec=lxterminal -x sh -c 'echo hello'
    Exec=sh -c 'gnome-terminal echo hello'
    Exec=sh -c 'echo hello'
    Exec=sh /bin/hello.sh
    Exec=sh -c /bin/hello.sh



But in the end all are the same (except when Terminal=false on line 9 there is no terminal, obviously).



I can see hello1 under System -> Accessories, but when I click on it still just a blank screen pops out. In debian 7.5 LXDE wheezy this is really easy to do successfully, but what is wrong in Lubuntu 14.04 to make it so much more difficult?



Andrew







lubuntu scripts lxterminal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago









wjandrea

9,10342363




9,10342363










asked Jan 1 '15 at 10:14









afc888nyafc888ny

5517




5517








  • 3





    Skip the HTML tags and format it as code (select and press press Ctrl-K). At the moment it is hard to say what's in your files and what's not.

    – muru
    Jan 1 '15 at 10:43











  • @muru I fixed it. Hopefully I didn't break anything.

    – wjandrea
    8 hours ago











  • How did you get that ls output? Why are there files like /usr/share/applications//bin/hello.sh? Why are you adding system-level files to test this instead of user-level (i.e. in ~/bin and ~/.local/share/applications). How are you using gedit without sudo to edit system-level files? Also note you have curly quotes in one of those exec lines: Exec=lxterminal -e “/bin/hello.sh” (I know this is an old question - just voicing my concerns in case of similar questions in the future.)

    – wjandrea
    8 hours ago
















  • 3





    Skip the HTML tags and format it as code (select and press press Ctrl-K). At the moment it is hard to say what's in your files and what's not.

    – muru
    Jan 1 '15 at 10:43











  • @muru I fixed it. Hopefully I didn't break anything.

    – wjandrea
    8 hours ago











  • How did you get that ls output? Why are there files like /usr/share/applications//bin/hello.sh? Why are you adding system-level files to test this instead of user-level (i.e. in ~/bin and ~/.local/share/applications). How are you using gedit without sudo to edit system-level files? Also note you have curly quotes in one of those exec lines: Exec=lxterminal -e “/bin/hello.sh” (I know this is an old question - just voicing my concerns in case of similar questions in the future.)

    – wjandrea
    8 hours ago










3




3





Skip the HTML tags and format it as code (select and press press Ctrl-K). At the moment it is hard to say what's in your files and what's not.

– muru
Jan 1 '15 at 10:43





Skip the HTML tags and format it as code (select and press press Ctrl-K). At the moment it is hard to say what's in your files and what's not.

– muru
Jan 1 '15 at 10:43













@muru I fixed it. Hopefully I didn't break anything.

– wjandrea
8 hours ago





@muru I fixed it. Hopefully I didn't break anything.

– wjandrea
8 hours ago













How did you get that ls output? Why are there files like /usr/share/applications//bin/hello.sh? Why are you adding system-level files to test this instead of user-level (i.e. in ~/bin and ~/.local/share/applications). How are you using gedit without sudo to edit system-level files? Also note you have curly quotes in one of those exec lines: Exec=lxterminal -e “/bin/hello.sh” (I know this is an old question - just voicing my concerns in case of similar questions in the future.)

– wjandrea
8 hours ago







How did you get that ls output? Why are there files like /usr/share/applications//bin/hello.sh? Why are you adding system-level files to test this instead of user-level (i.e. in ~/bin and ~/.local/share/applications). How are you using gedit without sudo to edit system-level files? Also note you have curly quotes in one of those exec lines: Exec=lxterminal -e “/bin/hello.sh” (I know this is an old question - just voicing my concerns in case of similar questions in the future.)

– wjandrea
8 hours ago












1 Answer
1






active

oldest

votes


















1














I have managed to duplicate your problem and have a solution.



As your research has told you, your original problem was having:



Terminal=true


together with:



Exec=lxterminal -e /bin/hello.sh


The only problem is, that when you use:



Terminal=false


the terminal closes after executing the script, though it does actually run your script. As your script produces so little output it is not humanly possible to see this taking place so it seems like a "blank screen popping out".



As far as I can see (from man lxterminal and from Google), there is no specific way to ask lxterminal to stay open after it has executed a script, so you have to change the bash script (i.e. your hello.sh) itself.



For example you could add either of the following to the end of your script.





  1. echo "Press [ENTER] to exit" && read




    • The terminal will wait for the user to hit Enter. (In fact to type anything followed by Enter.)




  2. /bin/bash




    • The terminal will stay open.




For a discussion of the general problem of stopping the shell from closing after executing a command, including information about other terminal emulators, see: How to run a script without closing the terminal?



By the way the semicolon at the end of the Desktop file doesn't do anything, so you might as well remove it.



Summary: The only change you need to make to your original desktop file is Terminal=false, but you need to add a line to the end of your bash script if you want to see that the script has run.






share|improve this answer


























  • Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

    – afc888ny
    Jan 5 '15 at 2:36













  • (con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

    – afc888ny
    Jan 5 '15 at 2:41











  • I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

    – harlandski
    Jan 5 '15 at 4:38











  • solved on [link]linuxquestions.org/questions/…

    – afc888ny
    Jan 7 '15 at 8:56













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f567646%2fdesktop-file-cant-run-script-in-terminal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I have managed to duplicate your problem and have a solution.



As your research has told you, your original problem was having:



Terminal=true


together with:



Exec=lxterminal -e /bin/hello.sh


The only problem is, that when you use:



Terminal=false


the terminal closes after executing the script, though it does actually run your script. As your script produces so little output it is not humanly possible to see this taking place so it seems like a "blank screen popping out".



As far as I can see (from man lxterminal and from Google), there is no specific way to ask lxterminal to stay open after it has executed a script, so you have to change the bash script (i.e. your hello.sh) itself.



For example you could add either of the following to the end of your script.





  1. echo "Press [ENTER] to exit" && read




    • The terminal will wait for the user to hit Enter. (In fact to type anything followed by Enter.)




  2. /bin/bash




    • The terminal will stay open.




For a discussion of the general problem of stopping the shell from closing after executing a command, including information about other terminal emulators, see: How to run a script without closing the terminal?



By the way the semicolon at the end of the Desktop file doesn't do anything, so you might as well remove it.



Summary: The only change you need to make to your original desktop file is Terminal=false, but you need to add a line to the end of your bash script if you want to see that the script has run.






share|improve this answer


























  • Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

    – afc888ny
    Jan 5 '15 at 2:36













  • (con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

    – afc888ny
    Jan 5 '15 at 2:41











  • I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

    – harlandski
    Jan 5 '15 at 4:38











  • solved on [link]linuxquestions.org/questions/…

    – afc888ny
    Jan 7 '15 at 8:56


















1














I have managed to duplicate your problem and have a solution.



As your research has told you, your original problem was having:



Terminal=true


together with:



Exec=lxterminal -e /bin/hello.sh


The only problem is, that when you use:



Terminal=false


the terminal closes after executing the script, though it does actually run your script. As your script produces so little output it is not humanly possible to see this taking place so it seems like a "blank screen popping out".



As far as I can see (from man lxterminal and from Google), there is no specific way to ask lxterminal to stay open after it has executed a script, so you have to change the bash script (i.e. your hello.sh) itself.



For example you could add either of the following to the end of your script.





  1. echo "Press [ENTER] to exit" && read




    • The terminal will wait for the user to hit Enter. (In fact to type anything followed by Enter.)




  2. /bin/bash




    • The terminal will stay open.




For a discussion of the general problem of stopping the shell from closing after executing a command, including information about other terminal emulators, see: How to run a script without closing the terminal?



By the way the semicolon at the end of the Desktop file doesn't do anything, so you might as well remove it.



Summary: The only change you need to make to your original desktop file is Terminal=false, but you need to add a line to the end of your bash script if you want to see that the script has run.






share|improve this answer


























  • Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

    – afc888ny
    Jan 5 '15 at 2:36













  • (con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

    – afc888ny
    Jan 5 '15 at 2:41











  • I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

    – harlandski
    Jan 5 '15 at 4:38











  • solved on [link]linuxquestions.org/questions/…

    – afc888ny
    Jan 7 '15 at 8:56
















1












1








1







I have managed to duplicate your problem and have a solution.



As your research has told you, your original problem was having:



Terminal=true


together with:



Exec=lxterminal -e /bin/hello.sh


The only problem is, that when you use:



Terminal=false


the terminal closes after executing the script, though it does actually run your script. As your script produces so little output it is not humanly possible to see this taking place so it seems like a "blank screen popping out".



As far as I can see (from man lxterminal and from Google), there is no specific way to ask lxterminal to stay open after it has executed a script, so you have to change the bash script (i.e. your hello.sh) itself.



For example you could add either of the following to the end of your script.





  1. echo "Press [ENTER] to exit" && read




    • The terminal will wait for the user to hit Enter. (In fact to type anything followed by Enter.)




  2. /bin/bash




    • The terminal will stay open.




For a discussion of the general problem of stopping the shell from closing after executing a command, including information about other terminal emulators, see: How to run a script without closing the terminal?



By the way the semicolon at the end of the Desktop file doesn't do anything, so you might as well remove it.



Summary: The only change you need to make to your original desktop file is Terminal=false, but you need to add a line to the end of your bash script if you want to see that the script has run.






share|improve this answer















I have managed to duplicate your problem and have a solution.



As your research has told you, your original problem was having:



Terminal=true


together with:



Exec=lxterminal -e /bin/hello.sh


The only problem is, that when you use:



Terminal=false


the terminal closes after executing the script, though it does actually run your script. As your script produces so little output it is not humanly possible to see this taking place so it seems like a "blank screen popping out".



As far as I can see (from man lxterminal and from Google), there is no specific way to ask lxterminal to stay open after it has executed a script, so you have to change the bash script (i.e. your hello.sh) itself.



For example you could add either of the following to the end of your script.





  1. echo "Press [ENTER] to exit" && read




    • The terminal will wait for the user to hit Enter. (In fact to type anything followed by Enter.)




  2. /bin/bash




    • The terminal will stay open.




For a discussion of the general problem of stopping the shell from closing after executing a command, including information about other terminal emulators, see: How to run a script without closing the terminal?



By the way the semicolon at the end of the Desktop file doesn't do anything, so you might as well remove it.



Summary: The only change you need to make to your original desktop file is Terminal=false, but you need to add a line to the end of your bash script if you want to see that the script has run.







share|improve this answer














share|improve this answer



share|improve this answer








edited 9 hours ago









wjandrea

9,10342363




9,10342363










answered Jan 1 '15 at 18:32









harlandskiharlandski

20117




20117













  • Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

    – afc888ny
    Jan 5 '15 at 2:36













  • (con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

    – afc888ny
    Jan 5 '15 at 2:41











  • I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

    – harlandski
    Jan 5 '15 at 4:38











  • solved on [link]linuxquestions.org/questions/…

    – afc888ny
    Jan 7 '15 at 8:56





















  • Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

    – afc888ny
    Jan 5 '15 at 2:36













  • (con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

    – afc888ny
    Jan 5 '15 at 2:41











  • I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

    – harlandski
    Jan 5 '15 at 4:38











  • solved on [link]linuxquestions.org/questions/…

    – afc888ny
    Jan 7 '15 at 8:56



















Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

– afc888ny
Jan 5 '15 at 2:36







Harlinski,    Thanks for your help, but when I try the first solution: >1. change hello.desktop file's contents from 'Terminal=true' to 'Terminal=false' >2. change 'hello.sh' contents >>FROM: >>>#!/bin/bash >>>echo 'Hello World!' >>TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>echo "Press [ENTER] to exit" && read >>OR TO: >>>#!/bin/bash >>>echo 'Hello World!' >>>/bin/bash >3. I removed the semi-colon at the end of my desktop file. >4. openbox –reconfigure >5. Press the button “hello” on the lxpanel Unfortunately, ...

– afc888ny
Jan 5 '15 at 2:36















(con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

– afc888ny
Jan 5 '15 at 2:41





(con't.)...Still now, like from the start, there is merely a new blank lxterminal that pops up and just sits there without any 'Hello World!' output.

– afc888ny
Jan 5 '15 at 2:41













I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

– harlandski
Jan 5 '15 at 4:38





I'm away from my Lubuntu box for a couple of weeks so can't directly help. All I can recommend is you strip down levels of complexity until you find the problem. So start with a user-owned desktop file on the Desktop calling a user-owned script, working up to your final configuration.

– harlandski
Jan 5 '15 at 4:38













solved on [link]linuxquestions.org/questions/…

– afc888ny
Jan 7 '15 at 8:56







solved on [link]linuxquestions.org/questions/…

– afc888ny
Jan 7 '15 at 8:56




















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f567646%2fdesktop-file-cant-run-script-in-terminal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How did Captain America manage to do this?

迪纳利

南乌拉尔铁路局