Thursday 20 August 2009

misleading error syntax error: word unexpected (expecting ")"

This error ("line 1: syntax error: word unexpected (expecting ")")") is misleading.
It leads one initially to suspect a scripting error.
It is because of trying to run an incompatible (maybe elf64) binary on an elf32 platform (x86/i386).

/sbin/udevd: line 1: syntax error: word unexpected (expecting ")")


It is quite like the misleading error you get in solaris 32bit or 64bit "Invalid argument" if trying to run an incompatible binary.

The error on x86_64 is good "cannot execute binary file" leads you to the problem directly.

$ ./hello32sparc
bash: ./hello32sparc: cannot execute binary file
$ ./hello64sparc
bash: ./hello64sparc: cannot execute binary file
$ ./hexdump_arm
bash: ./hexdump_arm: cannot execute binary file
$ uname -s -r -m -p -i -o
Linux 2.6.27.29-170.2.79.fc10.x86_64 x86_64 x86_64 x86_64 GNU/Linux



$ ./hexdump
-bash: ./hexdump: Invalid argument
$ ./hexdump_arm
-bash: ./hexdump_arm: Invalid argument
$ ./hexdump
hexdump hexdump_arm hexdumpx86_32 hexdumpx86_64
$ ./hexdumpx86_32
-bash: ./hexdumpx86_32: Invalid argument
$ ./hexdumpx86_64
-bash: ./hexdumpx86_64: Invalid argument
$ uname -s -r -m -p -i
SunOS 5.10 sun4u sparc SUNW,Sun-Fire-V245


Use objdump to check what platform your binaries are for.

objdump -h hello32sparc
elfdump -e hello32sparc

No comments: