Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Can't run shell scripts with double click

  1. #1

    Default Can't run shell scripts with double click

    Forgive me if this is in the wrong place.

    My problem is rather simple. Before switching to openSUSE I used to use linux mint. On there I could write a script, make it executable then when I double-clicked on it a terminal window would open showing me my script running. The script isn't even a script as much as it is just a convenience, I'm simply trying to create and 'update' script that I can double click instead of opening up a terminal then starting to type or using yast etc.

    Here's the code:
    Code:
    #!/bin/bash
    sudo zypper patch
    sudo zypper up
    fortune
    At first when I double clicked on it, it would complain about having no suitable application about opening a shell script, so I added konsole to the top of the preferred apps list in the file's properties and made sure I hadn't just made a typo when making it executable so I ran 'chmod +x file' again.

    Now however, it doesn't do anything. It doesn't open but there's no error either. I thought it may be running in the background but
    Code:
    ps aux | grep Update
    (Update is the file name of the script)
    and
    Code:
    ps aux | grep zypper
    Both only show the one line of output that we all know is just the process that I just ran with ps aux. So, how do I get a bash/sh script to run in a visible terminal window when I double click on it? I fear this may be painfully simple to the point where I'll be embarrassed about asking but I can't think of anything else

    All help is appreciated.

  2. #2

    Default Re: Can't run shell scripts with double click

    Hi, try with /bin/sh instead of /bin/bash. HTH Lenwolf

  3. #3

    Default Re: Can't run shell scripts with double click

    I already tried that. Same result.

  4. #4

    Default Re: Can't run shell scripts with double click

    Quote Originally Posted by CyberShrek View Post
    So, how do I get a bash/sh script to run in a visible terminal window when I double click on it?
    And _where_ do you "double click on it"? In a file manager? Which one? The file manager (or desktop environment) has to run it in a terminal window in that case. How you set that up would depend at least on which DE you use.

  5. #5

    Default Re: Can't run shell scripts with double click

    On my desktop.

    I'm running kde 4.14.6. The file manager I use is dolphin.

    It's very strange that extra legwork is required for this considering on other distros (or probably more accurately put: in other desktop environments) you can simply make a file with a script in and run it with a double-click.

  6. #6
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,004

    Default Re: Can't run shell scripts with double click

    Quote Originally Posted by CyberShrek View Post
    you can simply make a file with a script in and run it with a double-click.
    i.am.not.an.rmfr.script.you.just.received.from.your.friend.as.a.joke.sh <double click> Aww, ****.
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  7. #7
    Join Date
    Sep 2012
    Location
    Colorado
    Posts
    51

    Default Re: Can't run shell scripts with double click

    Maybe try:

    Code:
    #!/bin/bash
    sudo konsole -e --noclose zypper patch && sudo zypper up && fortune
    Under Dolphin, change the program to execute from konsole to sh.

    I did this ALONG time ago, never been extremely good at the console, always just fly by the seat of my pants.
    But if I remember correctly, this should work, maybe.

  8. #8
    Join Date
    Sep 2012
    Location
    Colorado
    Posts
    51

    Default Re: Can't run shell scripts with double click

    By the way, if this worked, please click on the star below my post, I am a little past the newbie stage and could use the up!

  9. #9
    Join Date
    Sep 2012
    Location
    Colorado
    Posts
    51

    Default Re: Can't run shell scripts with double click

    Dangit! mistype:

    Code:
    #!/bin/bash
    konsole -e --noclose sudo zypper patch && sudo zypper up && fortune
    There, corrected.

  10. #10

    Default Re: Can't run shell scripts with double click

    Quote Originally Posted by CyberShrek View Post
    It's very strange that extra legwork is required for this considering on other distros (or probably more accurately put: in other desktop environments) you can simply make a file with a script in and run it with a double-click.
    Well, as you corrected yourself, this has absolutely nothing to do with the distribution, but only with the desktop environment.
    On Mint you probably didn't use KDE. You could do the same in openSUSE, there's GNOME, XFCE, LXDE, E17, LXQT, MATE, ... available.
    You could even just use a different file manager in KDE, that would run your script in a terminal window automatically.

    One way to set this up in KDE would be to create a "link" (a .desktop file actually) via right-click->New->Link to Application..., set your script as command to run on the "Application" tab, and enable "Run in terminal" in the "Advanced Options" there.

    But depending on what you actually want to do in that script, there might be better ways to do it than with a script on your desktop.

    Btw, there's no need to run "zypper patch" if you run "zypper up" immediately afterwards...
    Last edited by wolfi323; 31-Mar-2015 at 10:09.

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •