I want to execute a command like this: "LD_PRELOAD=/path/to/my/so ./a.out"
so I wrote a shell script:
cmd="LD_PRELOAD=/path/to/my/so ./a.out"
${cmd}
Error occured:
LD_PRELOAD=/path/to/my/so : no such file or directory
By the way, the file /path/to/my/so exists and I can successfully execute the command in a bash.
Anything wrong?
It would be more traditional to just do something like this in your script:
export LD_PRELOAD=whatever
./a.out
It's looking for an executable called LD_PRELOAD=/path/to/my/so in your path and can't find it. You can use eval to get around this:
eval $CMD
Or, equivalently:
bash -c "$CMD"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With