Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

crontab -l:

* * * * * /Users/michel/Desktop/myScript.sh

myScript.sh:

#!/bin/bash
/usr/local/bin/growlnotify -t 'Fact' -m "$(/Users/michel/Desktop/anotherScript.sh data.txt)" -n 'myApp'

it doesn't tell an error, but growlnotify's message is empty, so "$(/Users/michel/Desktop/anotherScript.sh data.txt)" didn't work.

but if I execute /usr/local/bin/growlnotify -t 'Fact' -m "$(/Users/michel/Desktop/anotherScript.sh data.txt)" -n 'myApp' from bash manually it works a s planned.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Shell scripts invoked from cron are non-login, non-interactive shells, which means they're invoked in a kind of drastically stripped-down environment, and they don't source any of the typical shell startup scripts (.profile, .bashrc, etc.).

I'm guessing that anotherScript.sh relies on something that's not available by default in this mode. Like something that's defined in the usual login- or interactive-shell startup files that didn't get sourced.

See bash's (excellent) man page about the different ways bash can get invoked, and which startup files it looks for in each case.

share|improve this answer
1  
The environment variables are different, PATH or LD_LIBRARY_PATH usually get you. You don't have a terminal either (I had stuff that broke on stty commands) –  Rich Homolka May 22 '13 at 17:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.