I have created a bash script and in crontab -e created an entry called
*/10 * * * * /command/
But when i try to execute the script from the crontab, it grabs a wrong value.
it runs
test=$(ifconfig en0 |grep -o 10.1.42)
where i have made 10.1.42 = true / it exists
when it then gets to an if then statement it takes the else, instead of the then.
if [ "$test" == "10.1.42" ]
then
(echo "Connection to the fileserver -> Level3 folder established" >> /Users/$hvem/startUpScripts/log)
/Users/$hvem/startUpScripts/Level3ExpectScript
else
(echo "Your not on the correct network 10.1.42.* didn't mount ${tid}" >> /Users/$hvem/startUpScripts/log)
fi
BUT if i run the script by "hand" ./scriptName it gets the corrects value and connects to a remote samba server i got, by the then instead of the else statement.
Whats going on with this script? Why docent it work correctly just because i execute it from the crontab?
Kind regards.
*/10 * * * * /command/
But when i try to execute the script from the crontab, it grabs a wrong value.
it runs
test=$(ifconfig en0 |grep -o 10.1.42)
where i have made 10.1.42 = true / it exists
when it then gets to an if then statement it takes the else, instead of the then.
if [ "$test" == "10.1.42" ]
then
(echo "Connection to the fileserver -> Level3 folder established" >> /Users/$hvem/startUpScripts/log)
/Users/$hvem/startUpScripts/Level3ExpectScript
else
(echo "Your not on the correct network 10.1.42.* didn't mount ${tid}" >> /Users/$hvem/startUpScripts/log)
fi
BUT if i run the script by "hand" ./scriptName it gets the corrects value and connects to a remote samba server i got, by the then instead of the else statement.
Whats going on with this script? Why docent it work correctly just because i execute it from the crontab?
Kind regards.