The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
error in running shell script in cron sari Shell Programming and Scripting 3 04-16-2008 05:09 AM
cron entry error capeme Shell Programming and Scripting 6 10-26-2006 10:05 AM
cron error capeme UNIX for Dummies Questions & Answers 4 10-25-2006 04:07 PM
mmap error - only when from cron?!?!? Bicks Filesystems, Disks and Memory 1 08-01-2006 02:12 PM
LAuS error messages in /var/log/cron soliberus Red Hat 1 05-18-2006 11:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-12-2002
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Script/cron error

I am running a script through cron but keep getting this message in unix mail:

Subject: cron

Not a terminal
stty: : Not a typewriter
stty: : Not a typewriter
logout

The script appears to run successfully. Any ideas what this message is and how I can stop it?
  #2 (permalink)  
Old 06-12-2002
killerserv's Avatar
killerserv killerserv is offline Forum Advisor  
Unix Predator
  
 

Join Date: Dec 2000
Location: Phoenix, AZ
Posts: 670
The not-a-typewriter error is caused by running commands where there is no controlling tty device; that is, no interactive terminal is present. This would be true for a script that runs in cron or has su - to run a batch job.

To prevent this, you need to start with /etc/profile and test for an interactive tty device as in:

Code:
case $- in

            *i* ) export INTERACTIVE=/sbin/true

                              ;;

                        * ) export INTERACTIVE=/sbin/false

                              ;;

esac

While this may seem cryptic, the shell understands whether it is interactive or not and sets a flag (the i flag). The construct $- returns all the current flags that are set as a string and if the letter i appears in the string, the shell is interactive. Another way is to test the terminal device with the tty(1) command as in:

Code:
if tty -s

then

         export TTY=/sbin/true

else

         export TTY=/sbin/false

fi

The choice of $TTY or $INTERACTIVE is arbitrary as far as names. In your /etc/profile (and .profile, etc.), you can then test for interactive terminal prior to any settings that affect the terminal. A few of the common commands are: stty, tput, and tabs. Here is an example:

Code:
if [ $TTY ]

then

     /sbin/stty erase "^H" kill "^U"

     /sbin/stty intr "^C" eof "^D"

     /sbin/stty -parity ixoff

     /sbin/stty susp \^Z dsusp \^Y

if [ -x /usr/bin/tabs ]

then

     /usr/bin/tabs

else

     echo "$0: The command \"/usr/bin/

               tabs\" was not found."

 fi

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0