Is there a way to generate a Bashscript dynamically using a Bashscript, change the mod of the generated Bashscript to allow execution, and then run the generated Bashscript?
Advertisement
Answer
yes it is totally feasible!
JavaScript
x
#!/bin/bash
FILE="/tmp/generated.bash"
cat <<END > $FILE
#!/bin/bash
echo "Hello There from generated script!"
END
chmod 755 $FILE
echo "running ...."
$FILE
echo "done"
gonna give you the output like :
JavaScript
[tmp]=> ./test.bash
running .
Hello There from generated script!
done