Operating System - HP-UX
1826440 Members
4127 Online
109692 Solutions
New Discussion

Re: ttytype error on shutdown

 
SOLVED
Go to solution
Rachel Smith_1
Occasional Advisor

ttytype error on shutdown

I have a script (scriptA), that calls another script (scriptB) which performs a shutdown of my HPUX box (11.00). If you look at scriptA it looks something like this :

#!/bin/ksh

/opt/scriptB &

#end of script

When this script executes, I get this error during the shutdown :

ttytype: couldn't change current tty settings: I/O error

If I run this script the same but DON'T run scriptB in the background, I don't get the error. What exactly is this?

Thanks,
Rachel
11 REPLIES 11
Graham Cameron_1
Honored Contributor

Re: ttytype error on shutdown

ttytype is a utility which interrogates the calling terminal to find out what kind it is, and reports back what it finds.

It does not normally attempt to change any settings, instead the values it reports are often used to drive subsequent terminal setting commands. See man ttytype.

It sounds as if in your case, ttytype is being called inappropriately.
Since you are shutting down in any case, it is probably no big deal, but if you are desparate to supress this message, you need to find the call to "ttytype" from within /opt/scriptB and debug it (or post it here).

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Rachel Smith_1
Occasional Advisor

Re: ttytype error on shutdown

The only thing in scriptB is this :

#!/bin/ksh
cd /
/sbin/shutdown -h -y now
#end of script

I never call ttytype, so I don't understand why I would be getting and error from it. Plus, it only happens when this script is being called and put to the background (with an "&"). Otherwise, I don't get this error.
Graham Cameron_1
Honored Contributor

Re: ttytype error on shutdown

OK

Change scriptB from

/sbin/shutdown -h -y now

to
/sbin/shutdown -h -y now
-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Mark Grant
Honored Contributor
Solution

Re: ttytype error on shutdown

When you run something in the background and termio calls are made, there is no associated terminal (we have all seen "not a typewriter" errors). I would guess ttytype gets a bit upset about finding the type of a non existant terminal.

I imagine ttytype gets run in shutdown at some point, persumably to do all that funky cursor positioning stuff it does.
Never preceed any demonstration with anything more predictive than "watch this"
Rachel Smith_1
Occasional Advisor

Re: ttytype error on shutdown

This "/sbin/shutdown -h -y now
/sbin/shutdown -h -y now 2>/dev/null

I am hoping there is a way to fix the error rather than just not seeing it.

John Palmer
Honored Contributor

Re: ttytype error on shutdown

I've not seen this behaviour on a vanilla HP-UX system. However 'ttytype' is called from /etc/profile.

Do you have any of your own shutdown scripts that call 'su - user -c command' ? The su - user is a common problem and is the usual cause of the 'not a typewriter' errors that Mark mentioned.

To fix it, you should replace
su - user -c command with
su user -c command
but ensure that the correct environment (exported variables, PATH etc) is either set-up before calling su or within 'command' itself.

Regards,
John
Rachel Smith_1
Occasional Advisor

Re: ttytype error on shutdown

No, I don't call any of the scripts using "su - ....", but if I do run the script that way, it does get rid of the error. Insead, I get this message when I run the command :

********************************************
WARNING! WARNING! WARNING! WARNING!
********************************************

THIS SYSTEM HAS BEEN BOOTED USING A TEMPORARY KERNEL!
DO NOT ATTEMPT TO INVOKE MULTI-USER RUN-LEVEL USING THIS KERNEL!

Type the following command from the shell prompt for more information about
completing the recovery process:

cat /RECOVERY.DOC


********************************************

Is this normal when using doing "su - user -c command"??
John Palmer
Honored Contributor

Re: ttytype error on shutdown

When I mentioned shutdown scripts, I meant scripts in /sbin/init.d that are linked from Knnn scripts in sbin/rc2.d etc. These are called by shutdown and also init when you change the runlevel.

What command are you running to get that message?

Rachel Smith_1
Occasional Advisor

Re: ttytype error on shutdown

I get that message when I run any command this way :

# su - root -c "echo HELLO"

I will get the message from that. If I run the command using any other id, I don't.

I checked and there doesn't seem to be any instance of ttytype is any file within /sbin/init.d...

John Palmer
Honored Contributor

Re: ttytype error on shutdown

So your message is probably coming from /.profile. Do you get it when you log in as root?

What you should be looking for in /sbin/init.d is any script that calls 'su -'.
Rachel Smith_1
Occasional Advisor

Re: ttytype error on shutdown

Yes, I do get that message when I log on as root (using su -).

There are not any scripts within /sbin/init.d that call any script with a "su -".