#!/bin/sh
# Author: thomas@corelatus.se
# Exercises an erlang bug when running this script via cron:
#
# When cron is starting erlang with shell activated, erlang dies
# with "*** Terminating erlang (nonode@nohost)"
# This is fine, but exit status is 0! This is wrong.

# Replace with path to wanted otp version
OTP=/u1/otp

# Start with shell activated
$OTP/bin/erl -s crontest go -pz /tmp

# Copy exit value
exit_status=$?

case $exit_status in
    100)
	echo "Erlang exit status 100. Normal result when everything is started ok."
	exit 0
	;;
    0)
	echo "Erlang exit status 0. Should never happen!"
	exit 1;
	;;
    *)
	echo "Exit status $exit_status."
	exit $exit_status
esac
