2

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
  • I'm not sure about a Bashscript, although in Bash it's possible to create a script, if attempted. Commented May 13, 2015 at 3:01

1 Answer 1

8

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.