How to correctly test for existence of pseudo tty?



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.

.



Relevant Pages

  • Re: Entourage account setup applescript not working
    ... I pasted the script at the end just in case. ... When comparing the account settings on 2 computers, ... This script assists a user with the setup of his Exchange account ... Customize the network and server properties below with information ...
    (microsoft.public.mac.office.entourage)
  • Re: Error 15401 using sp_grantlogin (not addressed by current KB articles)
    ... Restarting Windows 2000 resolved the problem for this particular account, ... confused when it sees a duplicate SID. ... > One way to get SQL Server to agree with the renamed NT ... > Preview (to ensure the script was created), ...
    (microsoft.public.sqlserver.security)
  • Re: Local account creation
    ... While this script works fine for my 2003 environment, ... use the script in a startup GPO so that there a generic local admin account ... Dim objNetwork, strComputer, strUser ...
    (microsoft.public.windows.server.scripting)
  • RE: Error 15401 using sp_grantlogin (not addressed by current KB articles)
    ... argument to get_sid, it returns a sid. ... The sysxlogins.name column stores the NT account ... One way to get SQL Server to agree with the renamed NT ... check "Script all objects", on the Formatting tab UNcheck "Generate the ...
    (microsoft.public.sqlserver.security)
  • Re: How to change default of "Add to Address Book" command
    ... Script Editor, I did access the group using Google simply because my ... even though the Entourage source for my message clearly says ... Exchange account's Contacts address book. ... If you happen to have more than one Exchange account then ...
    (microsoft.public.mac.office.entourage)