How to run a script from another script

Hi! I'm trying to add a Custom Application Launcher to the top panel. I want to launch a bash-based script by clicking on this Custom Launcher but nothing happens. The script I want to run is without extension (its name is only "menu") and is placed in /home/peppe130/Development/Android-Kitchen. It is an interactive script..

I already tried to put the script's PATH in the Launcher's Command field but nothing happens. Any solution? Thanks :slight_smile:

Did you check the script you want to call is executable?
Did you try all the options below? (source):

There are a couple of ways you can do this:

  1. The first is to make the other script executable, add the #!/bin/bash line at the top, and the path where the file is to the $PATH environment variable. Then you can call it as a normal command.
  2. Call it with the source command (alias is .) like this: source /path/to/script.
  3. Use the bash command to execute it: /bin/bash /path/to/script.
    The first and third methods execute the script as another process, so variables and functions in the other script will not be accessible. The second method executes the script in the first scripts process, and pulls in variables and functions from the other script so they are usable from the calling script.
1 Like

Thank you very much :slight_smile: Just another question… If I want to launch a script in a new terminal window from another script, how can I do this?

Inside your first script (the one that is being used to execute the other script):

you need to prefix the script name (the one you are trying to execute) with ./

So, for example ./myscript.sh

However, if the script you are trying to execute is not in the same directory as the directory you are in when you try to run it, then you also need to prefix the above with a path to the script.

For example

./path-to-my-script/myscript.sh

1 Like

Hi Steve! I have another question… I made some script to compile/decompile Android applications and I put them in the nautilus menu (nautilus-script)… Usually when I launch in the terminal for example the command to decompile an app (apktool d app.apk) is showed up an output that tells me if everything went right or wrong… Instead, when I launch the script to decompile an app from the nautilus-script, no outputs are showed up… How can I launch a script command in the terminal? My aim is to launch the script, open the terminal and run the command in the terminal… Actually when I run the script, it works in background… Thanks :slight_smile:

Solved… Just write -x

How to keep the terminal opened after running a script? When I launch the script from the nautilus-script, it closes the terminal after it finishes its operations and I don’t have the time to read the output… Any solution?

You request input from the user (which you simply discard) to get the equivalent of the PAUSE command in MS-DOS.

read -p "Press [Enter] to close the terminal."
1 Like

Unfortunately neighter this worked :confused: Terminal keeps closing itself automatically