SNMP "exec format error" when trying to run a script

wolf2600 picture wolf2600 · Nov 16, 2013 · Viewed 8.9k times · Source

I'm using SNMPD to run a script on a Raspberry Pi with net-snmp. I was able to get the same script running on my Slackware machine, but on the Pi, under extOutput.1, I'm getting "Exec format error".

The batch file being called is set to 777 and is:

#! /bin/bash
/sbin/reboot

Everything I've found about the error says that I would just need to include the #! at the beginning of the file and that would fix it, but it doesn't. I can run the script from the command prompt just fine, and /bin/bash obviously works also, but when called through SNMP (both snmpget and snmpwalk), the extOutput.1 line gives me that error.

Answer

wolf2600 picture wolf2600 · Nov 16, 2013

Ugh. I had a blank line at the top of the script before the #! line.