I have a script that updates the server with some statistics once a day. The script works as intended when launched from the command line, but when launched from cron, some variables are not passed to curl.
Here is a sample code:
PATH=/bin:/sbin:/usr/bin:/usr/sbin
/bin/sh /etc/profile
MACADDR=$(ifconfig en0 | grep ether | awk '{print $2}')
DISKUSED=$(df / | awk '{print $3}' | tail -n1)
DISKSIZE=$(df / | awk '{print $2}' | tail -n1)
GET_DELIM="&"
GET_MAC="macaddr"
GET_DS="disk_size"
GET_DU="disk_used"
QUERY1=$GET_MAC=$MACADDR$GET_DELIM$GET_DS=$DISKSIZE$GET_DELIM$GET_DU=$DISK_USED
curl http://192.168.100.150/status.php?$QUERY1
The result of the cron job is http://192.168.100.150/status.php?macaddr=&disk_size=&disk_used=
I'm not sure if this is a problem with variables or possibly awk trying to parse data without a specified terminal size, etc.
Any help is appreciated.
source
share