Results 1 to 3 of 3

Thread: Bash scripts won't launch from gnome-menu unless they cd into target directory

  1. #1
    Join Date
    Apr 2008
    Beans
    149

    Question Bash scripts won't launch from gnome-menu unless they cd into target directory

    This is very odd, but whenever I make a launcher in gnome-menu or gnome-panel that launches a shell script, they will not work properly unless the script explicitly cd into the directory where the files that the script deal with are located. These scripts work just fine when run manually in a terminal, and when executed by clicking them in nautilus, but for some reason gnome-menu and gnome-panel are special, and won't execute the scripts properly.

    Is there something special about the gnome launching mechanism that requires modified scripts? Is there something about my scripts that is missing?

  2. #2
    Join Date
    Oct 2007
    Location
    Umeå, Sweden
    Beans
    100
    Distro
    Ubuntu

    Cool Re: Bash scripts won't launch from gnome-menu unless they cd into target directory

    Yes whenever you launch a program from the menu or panel, the default current directory will probably be the $HOME directory. Thus you will unfortunately have to explicitly change the directory.

    You could change the launcher to run it in a terminal and then modify the script to print the current directory by just adding a line:

    pwd
    or
    echo $PWD

    to verify that the script's current directory is your $HOME directory.

  3. #3
    Join Date
    Dec 2007
    Location
    Gainesville, Florida
    Beans
    Hidden!
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash scripts won't launch from gnome-menu unless they cd into target directory

    Whenever you write a script use full path names instead of assuming the current working directory. With that you can run the script from any directory.

Tags for this Thread

Bookmarks

Posting Permissions

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