tags:

views:

50

answers:

2

In bash, how can I convert an hex-encoded string like this:

2e2f65202d6b2022616622

or

\x2e\x2f\x65\x20\x2d\x6b\x20\x22\x61\x66\x22

(or something similiar) to:

./e -k "af"

... and then execute it?

Thanks!

+1  A: 
eval `printf "\x2e\x2f\x65\x20\x2d\x6b\x20\x22\x61\x66\x22"`
Sean Bright
A: 

The most appropriate way I can think of to do this would be through a function.

For example:

exec_hex_str() {
    cmd_val=$(printf "$1")
    echo "Executing: $cmd_val"
    eval $cmd_val
}
Bryan