Operating System - HP-UX
1752538 Members
4756 Online
108788 Solutions
New Discussion

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

 
Syedfurquan
Trusted Contributor

ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

Hello Expert,

 

I am getting below error when using crontab jobs. Please help me to fix this issue.

I am using Hp-UX 11.23.... The cron job was running fine from past many days suddenly from 1 weeks this error start coming

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

shutdown the PROD Instance for 20-10-2013

 

 

Sun Oct 20 23:59:00 WAT 2013

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

stty: : Not a typewriter

(c)Copyright 1983-2003 Hewlett-Packard Development Company, L.P.

(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California (c)Copyright 1980, 1984, 1986 Novell, Inc.

(c)Copyright 1986-2000 Sun Microsystems, Inc.

(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology (c)Copyright 1989-1993  The Open Software Foundation, Inc.

(c)Copyright 1990 Motorola, Inc.

(c)Copyright 1990, 1991, 1992 Cornell University (c)Copyright 1989-1991 The University of Maryland (c)Copyright 1988 Carnegie Mellon University (c)Copyright 1991-2003 Mentat Inc.

(c)Copyright 1996 Morning Star Technologies, Inc.

(c)Copyright 1996 Progressive Systems, Inc.

 

 

                  RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause in DFARS 252.227-7013.

 

 

                  Hewlett-Packard Company

                  3000 Hanover Street

                  Palo Alto, CA 94304 U.S.A.

 

Rights for non-DOD U.S. Government Departments and Agencies are as set forth in FAR 52.227-19(c)(1,2).

Not a terminal

stty: : Not a typewriter

stty: : Not a typewriter

 

 

        2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2

 

You are running addlnctl.sh version 115.7

 

Logfile: /u01/proddb/9.2.0/appsutil/log/PROD_gfhdbp/addlnctl.txt

 

Shutting down listener process prod ...

 

 

addlnctl.sh: exiting with status 0

logout

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

stty: : Not a typewriter

(c)Copyright 1983-2003 Hewlett-Packard Development Company, L.P.

(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California (c)Copyright 1980, 1984, 1986 Novell, Inc.

(c)Copyright 1986-2000 Sun Microsystems, Inc.

(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology (c)Copyright 1989-1993  The Open Software Foundation, Inc.

(c)Copyright 1990 Motorola, Inc.

(c)Copyright 1990, 1991, 1992 Cornell University (c)Copyright 1989-1991 The University of Maryland (c)Copyright 1988 Carnegie Mellon University (c)Copyright 1991-2003 Mentat Inc.

(c)Copyright 1996 Morning Star Technologies, Inc.

(c)Copyright 1996 Progressive Systems, Inc.

 

 

                  RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause in DFARS 252.227-7013.

 

 

                  Hewlett-Packard Company

                  3000 Hanover Street

                  Palo Alto, CA 94304 U.S.A.

 

Rights for non-DOD U.S. Government Departments and Agencies are as set forth in FAR 52.227-19(c)(1,2).

Not a terminal

stty: : Not a typewriter

stty: : Not a typewriter

 

 

        2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2      2

 

You are running addbctl.sh version 115.10

 

 

Shutting down database PROD ...

 

 

SQL*Plus: Release 9.2.0.7.0 - Production on Sun Oct 20 23:59:01 2013

 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

 

Connected.

Database closed.

Database dismounted.

ORACLE instance shut down.

Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.7.0 - Production

 

addbctl.sh: exiting with status 0

 

logout

 

 

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

Cron: The previous message is the standard output

      and standard error of one of your crontab commands:

 

/apps_backup/scripts/shutdown.bic # shuts down the PROD database

 

 

P.S. This thread has been moevd from HP-UX > Secrity to languages. - Hp Forum Moderator

 

Regards,
Syed
20 REPLIES 20
Bill Hassell
Honored Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

As with all profiles supplied by HP, they are not suitable for batch jobs. *Every* /etc/profile and *every* .profile needs to be modified to bypass interactive commands, that is, any command that requires a connected terminal.  Some of the commands are:

 

ttytype

tabs

stty

tset

 

And there are other profile commands that are simply not used in batch mode such as:

 

news

mail

cat /etc/motd

MANPATH=

cat /etc/copyright

changetape

 

So the first step is to determine what has been customized in your profiles:

 

diff /etc/profile /usr/newconfig/etc/profile
diff <root's $HOME>.profile /usr/newconfig/.profile
diff /etc/skel/.profile /usr/newconfig/etc/skel/.profile

 Save these differences so you can add them back to the revised profiles.

 

FIRST: Replace /etc/profile with this code:

 

## /etc/profile

## Handle interactive/terminal sessions here if tty -s then trap "" 1 2 3 eval $(ttytype -s) # ID the terminal export ERASE="^H" # Fix backspace LINES=${LINES:-""} # preset to "" if undefined (GSP/MP/iLO) COLUMNS=${COLUMNS:-""} if [[ "$LINES" = "" || "$COLUMNS" = "" ]] then eval $(resize) # terminal ID is not clean - fixup with resize [[ "$LINES" = "" ]] && LINES=24 # failsafe assignment [[ "$COLUMNS" = "" ]] && COLUMNS=80 fi echo "To read copyright, type: cat /etc/copyright" stty erase "^H" kill "^U" intr "^C" eof "^D" -parity ixoff stty susp \^Z dsusp \^Y tabs echo "$(tput rmln)$(tput sgr0)\c" # Turn off labels HN=$(hostname) HN=${HN%%.*} # simple hostname, no FQDN [[ $(id -u) -eq 0 ]] && TAG="#" || TAG="$" # PS1 shows lowest 2 directories only export PS1='$HN ${PWD##${PWD%/*/*}/} $TAG ' [[ -r /etc/MANPATH ]] && MANPATH=$(cat /etc/MANPATH) || MANPATH=/usr/share/man:/usr/contrib/man:/usr/local/man trap 1 2 3 ## end of interactive fi ## Setup common items here if [[ ! -d /usr/sbin ]] then PATH=$PATH:/sbin elif [[ -r /etc/PATH ]] then # Insure that $PATH includes /usr/bin [[ $(grep -c -e "^/usr/bin$" \ -e "^/usr/bin:" \ -e ":/usr/bin:" \ -e ":/usr/bin$" \ /etc/PATH) -eq 0 ]] && PATH=`cat /etc/PATH` || PATH=$PATH:$(cat /etc/PATH) fi

Then add your custom code from the old /etc/profile such as extra PATH values, and sourcing application variables. Be sure to remove any obsolete code such as TERM=vt100. The above code handles the TERM settings for any common terminal or terminal emulator.

 

 


As far as your .profile, you can replace all the code with just code specific to the user's login. Things unique to a specific user might be aliases and additional PATH settings.

 

 



Bill Hassell, sysadmin
Syedfurquan
Trusted Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

Hi Bill,

 

The following command didn't gave any o/p

 

# diff /etc/profile /usr/newconfig/etc/profile
# diff /etc/skel/.profile /usr/newconfig/etc/skel/.profile

 

Then as per your suggestion I tried to edit the /etc/profile with the provided script from you in the above post.

 

After editing the /etc/profile still getting the same error. Attaching error logs, /etc/profile o/p and .profile o/p for your reference.

 

I haven't done anything to .profile till now

 

Anyhelp how to fix this issue.

 

Regards,

Syed

Regards,
Syed
Dennis Handly
Acclaimed Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

>After editing the /etc/profile still getting the same error.

 

You're .profile is still broken.  Though Bill didn't mention how to fix it.

This is what's broken:

# Be sure that VUE does not invoke tty commands

    if [ ! "$VUE" ]; then

   # Set up the terminal:

 

Probably the simplest fix is:

if [ ! "$VUE" ] && tty -s; then

Syedfurquan
Trusted Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

Hi Dennis,

 

Thanks for your help and prompt response.

 

As per your suggestion I have edited the .profile and attached it for your confirmation also.

 

Now I will monitor my crontab scheduled job runing at midnight everyday to see if still this error is coming. Will keep you posted.

 

Regards,

Syed

Regards,
Syed
Syedfurquan
Trusted Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

Hello Expert,

 

After editing /etc/profile & .profile as per suggestion still getting the same error.

 

Please help out to resolve this issue.

 

Attaching the "/etc/profile" & ".prfoile" and "crontab" error. Please help

 

Regards,

Syed

Regards,
Syed
Dennis Handly
Acclaimed Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

>After editing /etc/profile & .profile as per suggestion still getting the same error.

 

You're going to have to put an echo in each file to see if you are actually getting the error from that file:

># /etc/profile

...

echo "In /etc/profile" 1>&2

if tty -s

 

> .profile:

echo "In ~/.profile" 1>&2

if [ ! "$VUE" ] && tty -s; then

 

Or add "set -x" to trace execution.

Bill Hassell
Honored Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

>> The following command didn't gave any o/p
>> # diff /etc/profile /usr/newconfig/etc/profile
>> # diff /etc/skel/.profile /usr/newconfig/etc/skel/.profile

 

This means that those two files are not modified.

 

However, the /etc/skel/.profile may not be the one used for your Oracle task.
If your cron job logs in as oracle, then run this command:

 

diff ~oracle/.profile /usr/newconfig/etc/skel/.profile

 

No output means that the oracle user's .profile is the standard local profile and needs replacing too. The default .profile is designed only for interactive logins and does not bypass these special commands. Since the example /etc/profile takes care of the terminal setup, move ~oracle/.profile to ~oracle/.profile_old and then put this short .profile in place for oracle:

 

# simple .profile (use with new /etc/profile in place)
echo "In $HOME/.profile"

 

That's all you need ASSUMING that the above diff command showed no output.
However, most Oracle logins need some environment changes so you need to add those differences to this 2 line script. These Oracle environment setups are critical so make sure they are in place.



Bill Hassell, sysadmin
Syedfurquan
Trusted Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

Hello Dennis & Bill,

 

Thanks for all your continous support.

 

As per Dennis suggestions I have edited and added the requested lines in /etc/profile and .profile. Please find the attachment for same.

 

Hi Bill,

 

I have removed the .profile from /home/oraprod and created a new file with the O/P you provided. I also added teh difference "diff /home/oraprod/.profile     /usr/newconfig/etc/skel/.profile" and added the same in new .profile.

Attached is the O/p for your response.

 

Please confirm if I have edited correctly.

 

Regards,

Syed

Regards,
Syed
Bill Hassell
Honored Contributor

Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter

No, this isn't correct at all.
You simply added the old code back into /etc/profile.

Let me explain:


There are two files used at login.
They are:

 

/etc/profile

 

and

 

.profile

 

.profile is in the login directory for each user.

 

Your problem is with the process running in cron.
You haven't told us what user is running when the process gets the errors so I have to guess that maybe it is the oracle user, is that correct?

 

If true, then .profile is located in the oracle user's home.

 

Again, I have no idea what the home directory might be on your system but it might be /home/oracle /.profile. That is the file that you or a senior system aadministrator must examine to determine what changes have been made. If you attach the user's .profile, perhaps we can figure it out.



Bill Hassell, sysadmin