0

src:unix programming environment

a shell script ./bundle :it works well with text file but binary code :(

#!/bin/bash
echo '# To unbundle , sh this file'
for i
do
    echo "echo $i 1>&2"
    echo "cat >$i <<'End of $i'"
    cat $i
    echo "End of $i"
done

a simple binary file named a.out,

% ./bundle a.out >> out
% chmod u+x out
% ./out # error happened

I got:

./out: line 8: warning: here-document at line 3 delimited by end-of-file (wanted `End of a.out')

yeah, I know the `End of a.out' should be in a seprate line. But I don't know how to implemetate it.

who have some idea?

thx in advance. :D

3
  • Related: stackoverflow.com/questions/10491704/… stackoverflow.com/questions/18410785/… Commented Dec 26, 2013 at 13:34
  • 1
    You could use base64 encode/decode, which is pretty standard these days... Commented Dec 26, 2013 at 14:12
  • @anishsane yeah, a cool method to do it! thx! base64 works very well. just use base64 instead of cat in shell script. :D Commented Dec 26, 2013 at 14:19

1 Answer 1

1

You can uuencode binary files (as shar does), or do as makeself does, appending the binary as is and reading it out with dd. (You could obviously also use either of these tools)

Sign up to request clarification or add additional context in comments.

1 Comment

thank you! uuencode works well. and I will try other method later.

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.