Why isn't exporting a variable working in the following case:
In the following example I export the PARAM variable and set the sleep to 1000 second in order to run the script as process on the background.
#!/bin/bash
export PARAM="I AM A REAL VALUE"
sleep 1000
so I execute the script as process as the following:
/tmp/example.bash &
Now script runs as a process (I checked it with ps -ef) and from the Linux console I want to print the $PARAM as the following
echo $PARAM
but no value from PARAM variable.
Why? The export from the script isn’t exporting the value when the script process is running.
.command or (in Bash or C shells) thesourcecommand to read the file. OTOH, you probably don't want to wait over 15 minutes to see the results; lose thesleep 1000.