executable binary to shell script

How to convert executable binary to shell script
Rajat SehgalFounder Enhance TechnologyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott SilvaNetwork AdministratorCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott SilvaNetwork AdministratorCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.