Search code examples
linuxbashshangstrom-linux

Strange "sh" behaviour


I am developing an application on Beaglebone board with Angstrom distrubition fo Linux.I faced an interesting problem.

When I execute :

sh /home/root/Desktop/BBTCP/out/vehicleDetect 192.168.10.29

in terminal it says

/home/root/Desktop/BBTCP/out/vehicleDetect:     /home/root/Desktop/BBTCP/out/vehicleDetect:         cannot execute binary file

But when i execute

cd /home/root/Desktop/BBTCP/

and

sh out/vehicleDetect 192.168.10.29

it starts working??

What is the reason and why I can't run tha application with first configuration?

I think it is about the difference between ./ and sh. What are the differences?


Solution

  • My first guess would be that one of the folders in the path /home/root/Desktop/BBTCP is a link. If vehicleDetect is a script and it invokes itself recursively, then this link might be confusing it.

    If that's not the case, try sh -x /home/root/Desktop/BBTCP/out/vehicleDetect and see what that prints.

    Lastly, check what's in the folder /home/root/Desktop/BBTCP. There might be an executable sh in there. If your path contains ., a different shell might be executed.