>> In a previous message, ges...@yahoo.com wrote: G> I am using this snippet of code in a bash script that is run via CRON. G> G> # See if we are running via CRON G> if [ ! -t 0 ] ... G> G> It runs fine from the console; however, when run via CRON, it outputs Tput: G> No terminal type specified and no TERM environmental variable.
On FreeBSD, I set an environment variable in the crontab file so I can check if something's being run via cron. This has the advantage of not depending on any scripting language. A sample crontab's below the signature. You can also set TERM to something harmless (say, vt100) but if something else is really expecting interactive behavior, that might come back to haunt you. The safest bet is to find out what's expecting TERM to be set and either wrap it... case "$CRON" in "") interactive code here ;; yes) ;; esac ...or get rid of it. -- Karl Vogel I don't speak for the USAF or my company Man who live in glass house, dress in basement. --Bryan Albright --------------------------------------------------------------------------- # Everything on a line is separated by blanks or tabs. # #+--------------------------- Minute (0-59) #| +----------------------- Hour (0-23) #| | +----------------- Day (1-31) #| | | +------------- Month (1-12) #| | | | +--------- Day of week (0-6, 0=Sunday) #| | | | | +---- Command to be run #| | | | | | #v v v v v v #======================================================================== # Shell variables CRON=yes #======================================================================== # Keep an eye on disk space. 4 * * * * /usr/local/cron/checkdrives # Store browser history. 59 23 * * * $HOME/cron/mozhist _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"