Contents
How does calling shell script from another shell script work?
It has access to the environment variables that are set in the system or shell. The system spawns a new process and executes the script in that process. This is appropriate if there is no variable values that it needs from the caller script.
How to write two shell scripts in Linux?
The first script will read input from user and the 2nd script will display this input in a loop till it detects an “exit” from the user. This is how I’ve coded the 2 shell scripts.
How to run multiple bash scripts simultaneously in a…?
You’re sending them (other than the last one) to the background. If you run the command chain you specify, the invocation ./script.sh 4will be in the foreground, and the other scripts will be running in the background. Input will be sent to the foreground script.
How does running a script in a different process work?
Running the script in a different process is like executing it from the command line. It has access to the environment variables that are set in the system or shell. The system spawns a new process and executes the script in that process. This is appropriate if there is no variable values that it needs from the caller script.
How to pass variables to the called script?
The only other way to do this is using co-processes, which do not seem to match your model. The tmp variable will have your value. You can do the same if you have to return more than 1 value. They will be all in the tmp variable separated by space. To use them put them into “parameters” (don’t forget to save true parameters of script 1):
How to save variables between runs of a script?
@Rodrigo I’ve used a similar approach before for “saving” values between runs of a script with some success. Just one thing to keep in mind, is that if multiple instances of the scripts run, things might get dicey. But if you save them in bash assignment form, you can just source the file to import the variables– FatalErrorMar 19 ’12 at 18:22