unix - Bash script containing binary executable -


is possible write bash script, contain binary executable program inside?

i mean script, contain dump of executable in textual form, dumped executable script when executed?

i love know solution, work out of box without need of installing additional packages. possible?

thanks!

i never done before ;) compile c source, create b.bash script containing binary (and original script simple development)

(a.bash)

#!/bin/bash  if [ "$0" == "b.bash" ];then   tail -n +$[ `grep -n '^binary' $0|cut -d ':' -f 1` + 1 ] $0 | base64 -d > a2.out   chmod +x a2.out   ./a2.out   echo $?   exit fi  cat "$0" > b.bash echo "binary" >> b.bash cat > a.c << eof int     main(){         return 12; } eof gcc a.c  base64 a.out >> b.bash 

invoke (a.bash generates b.bash):

bash a.bash ;bash b.bash 

i don't know how evade writing out binary temporary file before execution...


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -