1752808 Members
5753 Online
108789 Solutions
New Discussion юеВ

stty: not a typewriter

 
SOLVED
Go to solution
Rick Garland
Honored Contributor

stty: not a typewriter

Got a script that runs as root, does the su - oracle -c dbstart/dbshut and works as expected for the most part. However, it comes back with "ttytype: couldn't open tty for reading stty: not a typewriter".

Been so long since I've had to deal with this and I cannot find anything docs for it.
What am I missing?

Many thanks!
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor
Solution

Re: stty: not a typewriter

Hi Rick!

Not a typewriter

"You can get this message from many sources. Usually, the message means you executed a program that expects to deal with a terminal and you have forced the program to deal with a different device." This is from document #HPUXERR01 (General HP-UX system error messages).

In some of my scripts I've defined a boolean as follows:

typeset INTERACTOK=0 && [ -t -eq 0 ] && INTERACTOK=1

Then I can conditionally execute code based on whether I started from a terminal (or not, as in cron).

Hope this helps. Regards!

...JRF...

James R. Ferguson
Acclaimed Contributor

Re: stty: not a typewriter

Rick:

Oh, one more. If your cron entry sources your profile for your script, then you will get this nasty complaint. The profile is full of stty goodies. I suspect that's closer to your problem.

Regards!

...JRF...
John Palmer
Honored Contributor

Re: stty: not a typewriter

Rick,

Your 'su - oracle ' is running the profile scripts for user oracle.

These include a call to 'ttytype' which tries to determine the terminal type and 'stty'.

Because these are being run from cron or a script not associated with a terminal, both commands complain.

Try just doing 'su oracle -c ' to avoid calling the profiles. You will have to ensure that the correct environment is setup however.

Regards,
John
Kofi ARTHIABAH
Honored Contributor

Re: stty: not a typewriter

Rick:

You could edit the ~oracle/.profile and perform a test such as:

if [ tty -s ] # are we logging in with a terminal?

and bypass the commands that would need terminal interaction.

man tty

cheers.
nothing wrong with me that a few lines of code cannot fix!
Alan Riggs
Honored Contributor

Re: stty: not a typewriter

I beliee Johnnailed it. Don't source the full oracle profile, simply specify the environment you actually require. We set ours up in /etc/oraenv which makes the task quite simple.
FOREST Michel
Frequent Advisor

Re: stty: not a typewriter

Hi Rick !

We have experienced the same problem. If you use this in a cron, maybe you can add the nohup command before yours to avoid the call to a tty.

Let me know if it has helped you.

Francois H.
A rookie in the HP Forum :)
FOREST Michel
Frequent Advisor

Re: stty: not a typewriter

You have this message because the system has not the correct TERM.
The solution is to add 2>&- after the command su - oracle -c "...".
Try this redirection, it should solve your problem.

Victor N.
A rookie in the HP Forum :)
Geetam
Frequent Advisor

Re: stty: not a typewriter

Rick

The scripts dbshut and dbstart are setting up the environment already.

There is no need to source .profile; ie do not use the - with su

su oracle -c "/opt/oracle/product/8.0.5/bin/dbstart"
CHRIS ANORUO
Honored Contributor

Re: stty: not a typewriter

Rick,

Andy and John are right. I use to have this messages in my /etc/rc.log files due from oracle startup scripts. Just change (su - oracle_sid -c database) to (su oracle_sid - database) in your /sbin/init.d file for oracle database startup/stop script.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.