Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

At the end, it looks like it's just a regular sh script:

[USER@MACHINE ~/Desktop/D] head -2 truecrypt-7.1-setup-x86 
#!/bin/sh
CHECKSUM=163123652

but @the scripts end:

[USER@MACHINE ~/Desktop/D] tail -2 truecrypt-7.1-setup-x86 
5��\V<Rx+÷o��6ܺF!&8�ʷ�����^��T4
Sk�!�0"�W���L�`���Su�VP�!m�]5����C'}�/���%�������8�4�?�N;:��zgf�q�14S%oL�hҌz����+����Ƥ<'��jN7)m�H�^�ɧa��:�S��󺽋�so[�$_�/Ø��&#X�+x����
                                                                                                                                                        Sd  hz=��H����)n�_�������48�,4�M�x�w��z�Mp��)�Ѩa=2a��0ۙI
���YI��`��om��0�3���,�}�ȇ��I.��G���x���g��ЌÞ%�H��4�ڛ{35��0�C!�$Fԝ�?�.�T�UǺEa���38sl)��[x"��,
                                                                                               /�/���o���hV���R�`���nʂ�a��ۛ=~{#��FV����35�5Y;k��D��[mK����9 *lY��hD�:��{n����۝�$^�'���w�!$��Ĝ������*�����!'�?����?����?�+�L#(+�V

well.. binary data.. how??

[USER@MACHINE ~/Desktop/D] file truecrypt-7.1-setup-x86 
truecrypt-7.1-setup-x86: POSIX shell script text executable
[USER@MACHINE ~/Desktop/D] 

How could the file contain ASCII + binary data too? The script is launched as a script, but ends with binary data? How can they do that?? How can I keep a "hello word" binary at the end of a script? [and launch the binary part from the script?]

share|improve this question
    
Looks like a shar or some variant thereof (en.wikipedia.org/wiki/Shar#). –  Ulrich Schwarz Dec 21 '11 at 7:15
    
Creating such a file is not difficult: cat script_text_file.sh binaryfile > file_that_contains_both.sh As far as invoking the binary from the shell, that I don't know. If the binary is compressed data, extraction may not be too hard if the extraction program "opens itself" and waits to perform decompression until it sees a header, which could be made not to appear until the binary part starts. –  ultrasawblade Sep 5 '12 at 14:31
add comment

3 Answers

The only difference between text and binary is how you interpret it. *nix tends to not interpret them, so mixing them in this manner is fine; the text part of the script can extract the contents of the binary part of the script using various commands.

share|improve this answer
add comment

This is a common trick I see in installers. Usually the binary part is an archive and the top has the commands to extract it.

share|improve this answer
add comment

"How could the file contain ASCII + binary data too?"

Simply because ASCII text is just a subset of binary data.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.