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?
1 Answer
yes it is totally feasible!
#!/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 :
[tmp]=> ./test.bash
running ....
Hello There from generated script!
done
Bashscript, although inBashit's possible to create ascript, if attempted.