Operating System - HP-UX
1825551 Members
2498 Online
109681 Solutions
New Discussion юеВ

ttytype: couldn't open /dev/tty for reading

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

ttytype: couldn't open /dev/tty for reading

Hi,

I get the error message "ttytype: couldn't open /dev/tty for reading" only when I run su - username -c "command".

I don't think it has to do with the profile because I get the error before it even starts the profile (I put set -x in the .profile). I can run it from the command line without a problem as well. It is only from cron. Any ideas?

Thanks!
5 REPLIES 5
OldSchool
Honored Contributor
Solution

Re: ttytype: couldn't open /dev/tty for reading

it sounds like you are trying to run this as either a cron job or an init script

you need to take a look at /etc/profile, as this runs before .profile and contains the ttytype command.

you need to stop that section from executing for "non-interactive" logins.
OldSchool
Honored Contributor

Re: ttytype: couldn't open /dev/tty for reading

see this thread for ways to test for interactive shell:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1047318
Coolmar
Esteemed Contributor

Re: ttytype: couldn't open /dev/tty for reading

Yes, I am running it from the cron and that is the only time I get the error. From the command line it is fine.
Peter Nikitka
Honored Contributor

Re: ttytype: couldn't open /dev/tty for reading

Hi,

if 'ttytype' is the only command in /etc/profile, which tries to access a tty, you can use
[ -t 1 ] && ttytype ...

Else put all unnecessary stuff for 'batch processing' into
if [ -t 1 ]
then
ttytype ...
who am I
fortune
...
fi

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Coolmar
Esteemed Contributor

Re: ttytype: couldn't open /dev/tty for reading

I copied the /etc/profile from another 11.23 system and it was back to normal.