Visit Our UNIX and Linux User Community


Script/cron error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script/cron error
# 1  
Old 06-12-2002
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  
Old 06-12-2002
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

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #276
Difficulty: Easy
OpenSolaris was based on Solaris, which was originally released by Sun in 1999.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. UNIX for Dummies Questions & Answers

Error while running a script through cron job

Hi Team, When i am running the below query manually it is giving me the right output i.e. export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH ADMIN=abc@abc.com CPU_HIGH=`sar|awk '{print $9}'|sort -n|head -5|sed -n 5p` CPU_MAX=`echo "scale=3; 100-$CPU_HIGH" | bc` CPU_LOW=`sar|awk '{print... (13 Replies)
Discussion started by: Ekamjot
13 Replies

3. Programming

error in running script in cron tab

Hi I am running the following script in cron tab: #!/usr/local/bin/php <?php $handle=fopen('xmlfile.xml',"w"); $xmlfile= file_get_contents('http://diur-plus.2me.co.il/xml.aspx'); fwrite($handle,$xmlfile); fclose($handle); /* * To change this template, choose Tools |... (1 Reply)
Discussion started by: programAngel
1 Replies

4. UNIX for Dummies Questions & Answers

cron error

Hi all, I am brand new in linux and not sure where to post this i posted it also on debian but i think this place would have been better. I have a cron log error which i am trying to locate if anyone has any ideas that would be really appreciated ################### Logwatch 7.3.6... (3 Replies)
Discussion started by: stav40
3 Replies

5. Debian

cron error

Hi all, I am brand new in linux and i have a cron lon error which i am trying to locate if anyone has any ideas that would be really appreciated ################### Logwatch 7.3.6 (05/19/07) #################### Processing Initiated: Thu Nov 10 06:25:26 2011 Date Range... (0 Replies)
Discussion started by: stav40
0 Replies

6. Solaris

Shell Script gives error when run through cron job.

Hi, The following shell script runs without any problem when executed manulally. USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1) if then find /arch/AUBUAT/ -type f -mtime +0 | xargs rm find /arch/AUBMIG/ -type f -mtime +0 | xargs rm fi But the same gives below... (6 Replies)
Discussion started by: ksadiq79
6 Replies

7. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

8. UNIX for Dummies Questions & Answers

Error while running the script through cron jobs .Please help me on this

Hi Everyone, I have written a korn shell script to shutdown my documentum docbase server and to restart it automatically on a weekly basis. My script is, When i execute this script manually, i was able to execute it successfully without any issues. I have scheduled this script in cronjob... (1 Reply)
Discussion started by: Sheethal
1 Replies

9. Shell Programming and Scripting

error in running shell script in cron

#!/bin/bash CLASSPATH=. #CLASSPATH=${CLASSPATH}:${INSTALL_PATH}home/squidlog/CopyFile.java CLASSPATH=${CLASSPATH}:${INSTALL_PATH}usr/java/latest/lib/*.jar javac CopyFile.java echo "CLASSPATH=$CLASSPATH" #home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile /usr/bin/java... (3 Replies)
Discussion started by: sari
3 Replies

10. UNIX for Dummies Questions & Answers

cron error

I am using the following cron entry to run a cron job every 4 hours and it is rejecting it: 0 */4 * * * /home/location/scriptname When I put this entry in cron is errors with: 0481-079 reached a symbol that is not expected. This is an AIX 5.3 system Any ideas? Thanks (4 Replies)
Discussion started by: capeme
4 Replies

Featured Tech Videos