Fixing stty errors during crontab scripts on HP-UX

By default if you run crontab scripts on a HP-UX machine, you might get error messages like this:
ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter
Not a terminal

The reason for these messages is that in /etc/profile (and maybe in the user's $HOME/.profile too) there're some calls to ttytype and stty. Both are looking for a terminal to set and in cron jobs there'll be no terminal. You can fix these warnings by surrounding the ttytype, stty and tset calls (and any other command that tries to use the terminal) with a condition like this:
if `tty -s`; then
  ...
fi

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

not a typewriter

Hello, I encounter exactly the problem you speak about on a HP-UX server.

Can you tem my where ddo Y have to make this condition?

I have tried In the .profile of the user, do I also have to do the same test in the /etc/profile?

Thanks a lot for your help.

Electronick

Re: not a typewriter

Actually you should adapt the idea to your situation. The point is that you get these kind of error messages, when something during the execution of a cron job tries to alter the terminal settings. In my case modifing /etc/profile solved the problem, in your case it might be something else (depends on what you're running as a cron job, what shell do you use, etc.).

Thank you for your

Thank you for your answer.

I had modified only the ~/.profile. The problem is solved.

Thanks!

helpful

Thanks, it's really helpful.