Applications Menu items: how to make them run a script ?
Hi list,
Little problem here... I just bought X-Plane, and added a menu entry for it in the Applications menu in the Game category... simple enough, works fine. However, I quickly realised that the hat switch on the joystick didn't work, well known problem I found out, well known solution too: run a program called "jhat" before starting X-Plane, then kill jhat afterward. So now instead of running X-Plane directly, I must run a script that starts jhat, then only X-Plane, then kills jhat. The script works just fine when I start it manually from the command line in a terminal window, from the directory it's in. However, when I updated the menu entry to start the script instead of the X-Plane executable, well nothing happens ! Old menu entry (works): "/home/vincent/X-Plane/X-Plane-i686" new entry (doens't work, fails silently): "/home/vincent/X-Plane/xplane.sh" Anyone managed to run a script from the Applications menu, what's the trick ?! :-) -- Vince -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
Applications Menu items: how to make them run a script ?
There are a couple of tricks for shell scripts:
(a) make sure the permissions are correct (i.e. executable) (b) make sure you're using absolute paths (c) remember the the #! at the start (d) use verbose error handling to stdout, for debugging, at least when you detect something wrong cheers stuart On Sun, Jul 20, 2008 at 10:03 PM, Vincent Trouilliez <vincent.trouilliez@modulonet.fr> wrote: > Hi list, > > Little problem here... > > I just bought X-Plane, and added a menu entry for it in the > Applications menu in the Game category... simple enough, works fine. > > However, I quickly realised that the hat switch on the joystick didn't > work, well known problem I found out, well known solution too: run a > program called "jhat" before starting X-Plane, then kill jhat afterward. > > So now instead of running X-Plane directly, I must run a script that > starts jhat, then only X-Plane, then kills jhat. > > The script works just fine when I start it manually from the command > line in a terminal window, from the directory it's in. > > However, when I updated the menu entry to start the script instead of > the X-Plane executable, well nothing happens ! > > Old menu entry (works): > > "/home/vincent/X-Plane/X-Plane-i686" > > new entry (doens't work, fails silently): > > "/home/vincent/X-Plane/xplane.sh" > > > Anyone managed to run a script from the Applications menu, what's the > trick ?! :-) > > > -- > Vince > > -- > ubuntu-users mailing list > ubuntu-users@lists.ubuntu.com > Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users > -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
Applications Menu items: how to make them run a script ?
On Sun, 20 Jul 2008 22:09:42 +1200
"Stuart A. Yeates" <syeates@gmail.com> wrote: > There are a couple of tricks for shell scripts: > (a) make sure the permissions are correct (i.e. executable) > (b) make sure you're using absolute paths > (c) remember the the #! at the start > (d) use verbose error handling to stdout, for debugging, at least when > you detect something wrong Thanks, unfortunately for me, a b and c are already satisfied :-( as for d, I don't know how to make the applications menu "verbose", as it just fails silently when I click on the menu item, doesn't pop up any error message for me to look at :-/ -- Vince -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
Applications Menu items: how to make them run a script ?
Vincent Trouilliez wrote:
> On Sun, 20 Jul 2008 22:09:42 +1200 > "Stuart A. Yeates" <syeates@gmail.com> wrote: > >> There are a couple of tricks for shell scripts: >> (a) make sure the permissions are correct (i.e. executable) >> (b) make sure you're using absolute paths >> (c) remember the the #! at the start >> (d) use verbose error handling to stdout, for debugging, at least when >> you detect something wrong > > > Thanks, unfortunately for me, a b and c are already satisfied :-( > > as for d, I don't know how to make the applications menu "verbose", as > it just fails silently when I click on the menu item, doesn't pop up any > error message for me to look at :-/ > Hi Vince. Try running the important parts of the script from within a subshell that redirects stdout and stderr: #!/bin/sh ( jhat & xplane & pkill jhat ) > /tmp/logfile 2>&1 -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
Applications Menu items: how to make them run a script ?
On Sun, 20 Jul 2008 08:05:17 -0500
"Mumia W." <paduille.4062.mumia.w+nospam@earthlink.net> wrote: > Try running the important parts of the script from within a subshell > that redirects stdout and stderr: > > #!/bin/sh > ( > jhat & > xplane & > pkill jhat > ) > /tmp/logfile 2>&1 Hi Mumia, I tried that, and all it shows is what the script does, not what the Applications Menu does. As I said, the script works fine (here it is): ******* #! /bin/sh ./jhat /dev/input/js0 4 5 & ./X-Plane-i686 killall jhat ******* when I start it from the command line, it works as expected, no problem here. The problem isn't the script from what I can see, but more in the Applications menu applet, which fails to run a valid/working script, and I don't know how to get debugging info from the GUI app that is the Application Menu. If I knew the name of the executable of the applet that handles the Application menu, I guess I could try removing it from the panel and restarting it, from the command line this time, hoping it would throw some messages in the terminal, to explain why it refuses to run my script. But I don't know how to find out what is the program name of a given applet. The panel itself is "gnome-panel" IIRC, but the Application menu itself.... I have no idea ! :-/ -- Vince -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
Applications Menu items: how to make them run a script ?
Vincent Trouilliez wrote:
> ******* > #! /bin/sh > ./jhat /dev/input/js0 4 5 & > ./X-Plane-i686 > killall jhat > ******* There's your problem. Your using ./jhat and ./X-Plane-I686 The script is looking in the working directory which is fine if you have cd'ed to the correct directory before invoking it but it won't work from a menu item because the working directory isn't right. If jhat and X-Plane are in the path change the script to be: > #! /bin/sh > jhat /dev/input/js0 4 5 & > ./X-Plane-i686 > killall jhat if they are not in the path change it to: > #! /bin/sh > cd /path/tp/xplane/dir > ./jhat /dev/input/js0 4 5 & > ./X-Plane-i686 > killall jhat (replacing the argument to cd to be the correct directory) -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
Applications Menu items: how to make them run a script ?
On Sun, 20 Jul 2008 16:17:47 +0100
Andy <stude.list@googlemail.com> wrote: > Vincent Trouilliez wrote: > > ******* > > #! /bin/sh > > ./jhat /dev/input/js0 4 5 & > > ./X-Plane-i686 > > killall jhat > > ******* > > There's your problem. Your using ./jhat and ./X-Plane-I686 > The script is looking in the working directory which is fine if you have > cd'ed to the correct directory before invoking it but it won't work from > a menu item because the working directory isn't right. > > if they are not in the path change it to: > > > #! /bin/sh > > cd /path/tp/xplane/dir Hmmm, newbie mistake then, I feel ashamed ! ;-) Thanks Andy, problem solved :o) -- Vince, going to hide in the corner... -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
| All times are GMT. The time now is 09:44 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.