We help IT Professionals succeed at work.

executable binary to shell script

How to convert executable binary to shell script
Watch Question

Scott SilvaNetwork Administrator

It can be done, in a fashion... You basically uuencode the binary and embed the encoded text at the end of the script. Then the script has to uudecode that text back into a binary...  

Or do you mean that you have an exexutable binary, and you want to replace it with a shell script? If so, the answer is probably no, unless you know exactly what the binary does, and what it does is replaceable by a series of linux commands.

If you want help with this, you'll have to provide a _lot_ more information about the binary.
> unless you know exactly what the binary does
i.e. by Reverse Engineering it.

If you have the source code, you might be able to rewrite that as a shell script. But more likely you would just tweak the source to do what you want.

You could also use a wrapper script, e.g.
cat /usr/bin/find.sh
echo "Usage: sudo find.sh [options] [path...] [expression]"
echo "Pass safe parameters to 'find' to be executed as root"
echo "Note, unsafe Actions in 'find' such as -remove and -exec are not passed"
echo "Special characters like double or single quotes might not work"
# sed is inefficient compared to shell Parameter Expansion, but simple and portable
PASSPARS=`echo $@ | sed -e 's/-remove[ $]//g'`
find ${PASSPARS}

Open in new window

Scott SilvaNetwork Administrator

Funny that the accepted solution isn't what the question was...
Mine actually converts a binary to a shell script...
But whatever...
Doubly amusing, as the scriptlet I posted was the answer I needed, rather than the answer to the question I'd asked in