How to correctly test for existence of pseudo tty?
- From: deanjones7@xxxxxxxxx
- Date: Mon, 10 Sep 2007 06:05:09 -0000
I'm trying to debug some scripts that are supposed to run at boot time
through an rc script in /sbin/init.d and I suspect there's an issue
related to the lack of an associated tty.
The scripts work fine if I run them interactively. In particular, its
a perl script that fails.
A calling shell script does an su to an account that assumes ownership
of the process. The account uses ksh and in its .profile it has this
snippet of code -
if tty -s; then
....
fi
To my surprise, when I ran the process from cron, I got this output in
a temporary log file -
ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter
Not a terminal
logout
It turns out that cron attaches a pty to the process it runs (unlike
init). Obviously, the above output was due to there being no attached
terminal.
So, how can I correctly check in the .profile script if there is an
attached terminal? That is, whether the login is interactive or not.
'tty -s' and 'pty -s' don't appear to do the right thing and I can't
find another command that checks this correctly.
.
- Follow-Ups:
- Re: How to correctly test for existence of pseudo tty?
- From: deanjones7
- Re: How to correctly test for existence of pseudo tty?
- Prev by Date: template for oracle
- Next by Date: Re: How to correctly test for existence of pseudo tty?
- Previous by thread: template for oracle
- Next by thread: Re: How to correctly test for existence of pseudo tty?
- Index(es):
Relevant Pages
|
|