Search code examples
linuxbashshellscriptinggnome

I can't run 'script2.sh' from 'script1.sh' (they are in the same folder and have 755 permission)


I have a dumb question and I hope you can help me .. I have "script1.sh" and "script2.sh", both have permissions 755 and are in the same folder

script1.sh:

#!/bin/bash
zenity --info --text="SCRIPT1.sh"
./script2.sh
exit 0

script2.sh:

#!/bin/bash
zenity --info --text="TEST SCRIPT2.SH "
exit 0

Make a cd to the folder containing the scripts, then (from the bash console) write:

./script1.sh

It runs all OK! ..the show 2 posts zenity

----------------------------------------

But the problem is here ...

If I create a shortcut 'gnome' (All Settings> Shortcuts> Keyboard) and income as /path/to/script1.sh command .. only the first message zenity is shown (script1.sh)

It means that fails to run 'script2.sh' from 'script1.sh' when pressure key combination... why? How could solve this problem?

Thanks you!


Solution

  • This will only work when you run script1.sh from the same directory script2.sh is in, since ./script2.sh says run script2 from the current directory.

    You can either set your PATH to include the directory containing the scripts, omitting ./ or put in the absolute pathname for script2.sh.