Well, there are two things I'd like to mention.
The $? variable is updated after
every command. So, first it reflects the exit value from the perl script. Then, after the echo, $? is the exit value of the echo command. The if-statement references the echo command's exit value. To save it, you'll need to do something like this:
Code:
#!/bin/bash
perl ./udp_weather2.pl
script_exit_value=$?
echo "exit code: ${script_exit_value} [AFTER]"
if [ "${script_exit_value}" -ne "0" ] ; then
echo "running again..."
perl ./udp_weather2.pl
else
echo "exit code is ${?}. if that's one wtf is the script doing???"
fi
The other thing is that the if-statement uses a numeric comparison (-ne) but uses string arguments. It might work, but it's a little unusual.