
Script to spaw and run a script
Thanks for the response. See answers below.
[snip]
I would like for the child script to be generated if needed. I may
add a removal after running the child script. I'm not sure on that.
Yes, my order is backwards, I should create it, run it, then remove it
if I decide that needs to be done.
What I intend is for the child script to have variables and it would
process those variables not the parent. Currently, the parent
processes the variables and then spits out the child script. The
downside is this defeats the possiblity of the child having internal
variables. I ran the script with a sh -x, see the results below.
--------script output---------
+ echo parent
parent
+ child_script
+ [ -f /tmp/child ]
+ rm /tmp/child
+ cat
+ date +%Y-%m-%d
#!/sbin/sh
today=2004-04-13;
echo "child on ";
+ chmod 755 /tmp/child
+ /tmp/child
child on
--------contents of child script---------
#!/sbin/sh
today=2004-04-13;
echo "child on ";
--------what I expected the child to look like---------
#!/sbin/sh
today=`date +%Y-%m-%d`;
echo "child on ${date}";
What happens is the parent processed the variables and then spit out
the child. I want the child to determine when it runs what the values
of the variables will be. As you can see, the $today variable does
not contain a value when it is needed by the echo command. Basically,
the parent is attempting to process some of what I need put into the
child, when all I want is for it to spit out the childs code with no
thought into it. This may be the behaviour, but it is not what I am
trying to achieve.
[snip]
I originally learned to program in C++. I know in sh you can use a
semi-colon to denote the end-of-line or the end of a command. Old
habit, I like seeing them to denote I have finished a command and am
ready to run a new one. Just my style I guess.
Thanks in advance.