On the parent shell (root) executing the following:
SESSION_RECORD=started
Output:
echo $SESSION_RECORD
started
However, when I check the status from a shell script, the value is not getting assigned. I am aware it creates a child and executes the script, which is why it doesn't take the variable.
Is there a way I can import that from the parent shell to the child shell? I don't want to use export as the root variable is dynamic.
script for ref:
#!/bin/bash
session=`echo $SESSION_RECORD`
echo $session
if [ "$session" == "started" ]
then
echo "screen records"
else
echo "screen not started"
fi
Basically, my script should check the value of the variable and if it matches it should get into the loop and execute commands further.
The value of the variable SESSION_RECORD
changes dynamically, so based on the value, I need to run a script.