0

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?

user1336117
  • 451
  • 3
  • 8
  • 17
  • *think it is about the difference between ./ and sh*: but both your examples use `sh`, neither uses `./`. – cdarke Sep 13 '12 at 14:49
  • 1
    What does "which sh" give in each directory, and what does "file path/to/vehicleDetect" give? – stark Sep 14 '12 at 00:42

2 Answers2

1

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.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I have found the solution, vehicledetect is not a script, it is an executable binary. so using sh is not true way. Thank you – user1336117 Sep 14 '12 at 11:57
0

Seems like /home/root/Desktop/BBTCP/out/vehicleDetect is invoking a binary file (an executable) that was built on a different architecture.

The main difference between sh and ./ is that ./ will attempt to execute the file itself as an executable, whereas sh will do that for you. It could be that there is a weird magic number at the start of the file, but you would expect sh to complain about that.

Best guess though it is a #! line at the start of the file which either contains invalid characters or refers to a strange file. Did you, for example, bring this script file from another operating system (like Windows) that has different line endings? I have seen similar effects when text file scripts have not been converted but just copied. Maybe you downloaded it in a strange format?

Check with od -xc /home/root/Desktop/BBTCP/out/vehicleDetect and look at the first line.

cdarke
  • 42,728
  • 8
  • 80
  • 84