So i have a script that is like this:
#!/bin/sh
VARA="elementary 1
elementary 2
nursery A
nursery B
highschool AZ"
echo "${ContentOfADifferentSCRIPT}" | sh
i do not have control over the script that is inside the variable "${ContentOfADifferentSCRIPT}".
however, i know that the script content of the variable ${ContentOfADifferentSCRIPT}" needs the content of the variable "${VARA}".
how do i make the ${VARA} variable available to the "${ContentOfADifferentSCRIPT}" variable when I pipe and run sh on it?
RudiC
2
You've got two options here:
-
export VARA
to make the variable part of the environment
-
echo "${ContentOfADifferentSCRIPT}" | VARA="$VARA" sh
to define the variable locally
1 Like
Third might be
$ content='echo $aa'
$ aa=hep
$ eval $content
hep
$
Juha
But an exit within content probably breaks things
1 Like
You have an sh that runs another sh?
Then perhaps you can run the code in variable in the current sh?
eval ${ContentOfADifferentSCRIPT}
(Just seeing the previous post - with the same idea.)
1 Like