Operating System - HP-UX
1832880 Members
2536 Online
110048 Solutions
New Discussion

Re: stty: : Not a typewriter

 
SOLVED
Go to solution
Arman Mahboobi
Advisor

stty: : Not a typewriter

Hello,

I am running a script through cron and I am receiving "stty: : Not a typewriter" message in my mail. Could anyone please assist.

Below is a list of stty commands in my profile.
###############################################
stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^Z"
[[ $TERM = vt220 ]] && stty erase "^?"
[[ $TERM = vt200 ]] && stty erase "^?"
stty hupcl ixon ixoff
tabs
###############################################
Thanks
6 REPLIES 6
Ollie R
Respected Contributor
Solution

Re: stty: : Not a typewriter

Hi Arman,

The error messages are telling you that you are trying to set up a terminal environment when there isn't one to set up - you are running your script from "cron".

The messages are harmless but you could maybe check in your .profile if it is being run from cron by using:
echo "$-"
and if there is an "i" in the returned string then the shell is interactive.

Hope this helps,

Ollie.
To err is human but to not award points is unforgivable
Patrick Chim
Trusted Contributor

Re: stty: : Not a typewriter

Hi,

The job run by cron do not assiociate with a terminal so the stty command will be failed when called. You can just skip it.

But if you want to define the stty command in your profile, you can make some checking before issue the command.

== Begin

tty > /dev/null
rc=$?

if [ $rc -eq 0 ]
then
stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^Z"
[[ $TERM = vt220 ]] && stty erase "^?"
[[ $TERM = vt200 ]] && stty erase "^?"
stty hupcl ixon ixoff
tabs
fi

== End

Regards,
Patrick
ASO CENTRAL
Advisor

Re: stty: : Not a typewriter

As mentioned, you must protect all tty commands fromj being run in /etc/profile and .profile since there is no tty. In addition to your list of stty and tabs, add any command with tput, ttytype and tset.

You can protect the commands with:

if [ -o interactive ]
then

fi
Arman Mahboobi
Advisor

Re: stty: : Not a typewriter

Hi,
Thanks for the response.

I have changed the .profile to look like this.

###############################################
tty > /dev/null
rc=$?
if [ $rc -eq 0 ]
then
stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^Z"
[[ $TERM = vt220 ]] && stty erase "^?"
[[ $TERM = vt200 ]] && stty erase "^?"
stty hupcl ixon ixoff
tabs
fi
###############################################

Now I am experiencing a different problem with the script.

stty: : Not a typewriter
/u/script
cannot create
stty: : Not a typewriter

From what I can see from the script its trying to redirect output to a logfile but its experiencing problems creating it.

The command being used is below,

exec >> $directory/$logfile 2>> $directory/$logfile

Although the script is not interactive can I not create a logfile? Do I have to set a different tty setting if its not interactive?

Your help is much appreciated.

Patrick Chim
Trusted Contributor

Re: stty: : Not a typewriter

Hi,

Of course you can create any logfile in a script either by command execution or cron.

The command you run is going to append to a log as you use '>>'. Then what is the owner of that file ? Can you have the permission to write on it ?

Regards,
Patrick
Arman Mahboobi
Advisor

Re: stty: : Not a typewriter

Thanks for that, it was an unrelated problem which occurred the same time I made the changes to the .profile.

Many Thanks