Re: ttytype: couldn't open /dev/tty for reading | stty: : Not a typewriter (756 Views)
Reply
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 1 of 21 (1,003 Views)

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

[ Edited ]

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

 

Please use plain text.
Honored Contributor
Bill Hassell
Posts: 14,124
Registered: ‎05-29-2000
Message 2 of 21 (989 Views)

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.

 

 

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 3 of 21 (957 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 4 of 21 (953 Views)

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

[ Edited ]

>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

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 5 of 21 (943 Views)

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

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 6 of 21 (935 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 7 of 21 (928 Views)

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.

Please use plain text.
Honored Contributor
Bill Hassell
Posts: 14,124
Registered: ‎05-29-2000
Message 8 of 21 (917 Views)

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

[ Edited ]

>> 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.

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 9 of 21 (905 Views)

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

Please use plain text.
Honored Contributor
Bill Hassell
Posts: 14,124
Registered: ‎05-29-2000
Message 10 of 21 (897 Views)

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.

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 11 of 21 (893 Views)

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

>I have edited and added the requested lines in /etc/profile and .profile.

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

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

 

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

>if tty -s

 

Leave out that "if".  I only had that to show you where to put that echo.  Move the echo up in both files.

 

>su - oraprod -c 'sh /u01/proddb/9.2.0/appsutil/scripts/PROD_gfhdbp/addlnctl.sh s top prod'

 

This will cause execution of the profile files (~oraprod/.profile) from your crontab.

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 12 of 21 (881 Views)

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

Hi Bill,

 

It looks I have confused you with my uploaded O/P. Here I am trying to explain you below what I actually did

 

# diff /home/oraprod/.profile /usr/newconfig/etc/skel/.profile
27,29d26
<
< #. /u01/proddb/9.2.0/PROD_gfhdbp.env
< . /home/oraprod/9i_profile

 

The user used to run the crontab is "oraprod" and I have edited its .profile as follows:

 

Original .profile of oraprod is in /home/oraprod/.profile

 

# more /home/oraprod/.profile

 

# @(#)B11.23_LR

 

# Default user .profile file (/usr/bin/sh initialization).

 

# Set up the terminal:

        if [ "$TERM" = "" ]

        then

                eval ` tset -s -Q -m ':?hp' `

        else

                eval ` tset -s -Q `

        fi

        stty erase "^H" kill "^U" intr "^C" eof "^D"

        stty hupcl ixon ixoff

        tabs

 

# Set up the search paths:

        PATH=$PATH:.

 

# Set up the shell environment:

        set -u

        trap "echo 'logout'" 0

 

...skipping...

 

# @(#)B11.23_LR

 

# Default user .profile file (/usr/bin/sh initialization).

 

# Set up the terminal:

        if [ "$TERM" = "" ]

        then

                eval ` tset -s -Q -m ':?hp' `

        else

                eval ` tset -s -Q `

        fi

        stty erase "^H" kill "^U" intr "^C" eof "^D"

        stty hupcl ixon ixoff

        tabs

 

# Set up the search paths:

        PATH=$PATH:.

 

# Set up the shell environment:

        set -u

        trap "echo 'logout'" 0

 

# Set up the shell variables:

        EDITOR=vi

        export EDITOR

 

#. /u01/proddb/9.2.0/PROD_gfhdbp.env

. /home/oraprod/9i_profile

 

 

Edited .profile in /home/oraprod/.profile as per your suggestion below:

 

 

# more /home/oraprod/.profile

 

echo "In $HOME/.profile"

#. /u01/proddb/9.2.0/PROD_gfhdbp.env

. /home/oraprod/9i_profile

 

 

Please let me know if it looks fine.

 

Hi Dennis,

 

As per your suggestion I have edited the /etc/profile and .profile as well.

 

Many thanks to both of you for the support.

 

Regards,

Syed

 

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 13 of 21 (874 Views)

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

>Please let me know if it looks fine.

 

I don't see the changes??

What's in /home/oraprod/9i_profile?

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 14 of 21 (796 Views)

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

[ Edited ]

Hello Denis,

 

Sorry for the late response as I was on a long vacation so couldn't work on this issue.

As requested please find  O/p

 

#more /home/oraprod/9i_profile ORACLE_HOME=/u01/proddb/9.2.0 export ORACLE_HOME

ORACLE_SID=PROD export ORACLE_SID

PATH=$PATH:$ORACLE_HOME/bin; export PATH

PATH=$PATH:$ORACLE_HOME/OPatch; export PATH

LD_LIBRARY_PATH=/u01/proddb/9.2.0/lib:/usr/dt/lib:/usr/openwin/lib:/u01/proddb/9.2.0/ctx/lib; export LD_LIBRARY_PATH

TNS_ADMIN=/u01/proddb/9.2.0/network/admin/PROD_gfhdbp export TNS_ADMIN

 

I have reverted my /etc/profile and .profiel to teh original as I was getting soem other error after editing .

 

Please help.

 

Attaching /etc/profile and .profile also

 

Please help to fix this issue

 

Regards

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 15 of 21 (788 Views)

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

[ Edited ]

>#more /home/oraprod/9i_profile

>ORACLE_HOME=/u01/proddb/9.2.0 export ORACLE_HOME

>ORACLE_SID=PROD export ORACLE_SID

>TNS_ADMIN=/u01/proddb/9.2.0/network/admin/PROD_gfhdbp export TNS_ADMIN

 

These three lines are missing the semicolon before the export keyword.

If you are using a real shell, you should switch to simpler ksh or POSIX shell export syntax:

export ORACLE_HOME=/u01/proddb/9.2.0

 

>In /etc/profile

/etc/profile[54]: Syntax error: `if' is not matched.

 

This is the junk that I mentioned in message #11 to remove:

if tty -s

 

>In ~/.profile

.profile[53]: Syntax error: `then' is not matched

 

Same here:

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

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 16 of 21 (783 Views)

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

Hi,

 

Now after editing "/home/oraprod/9i_profile" it looks as below:

 

 

# more /home/oraprod/9i_profile

 

ORACLE_HOME=/u01/proddb/9.2.0;

export ORACLE_HOME

 

ORACLE_SID=PROD;

export ORACLE_SID

 

PATH=$PATH:$ORACLE_HOME/bin; export PATH

 

PATH=$PATH:$ORACLE_HOME/OPatch; export PATH

 

LD_LIBRARY_PATH=/u01/proddb/9.2.0/lib:/usr/dt/lib:/usr/openwin/lib:/u01/proddb/9.2.0/ctx/lib;

export LD_LIBRARY_PATH

 

TNS_ADMIN=/u01/proddb/9.2.0/network/admin/PROD_gfhdbp;

export TNS_ADMIN

 

 

Then after that I did

 

export ORACLE_HOME=/u01/proddb/9.2.0

 

Is it fine now? As mentioned in my last post I have reverted back my /etc/profile and .profile as old and attached for your reference.

 

Regards,

Syed

 

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 17 of 21 (776 Views)

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

[ Edited ]

>Is it fine now?

 

Well, if you have two lines, you don't need that semicolon.

And if you don't get those syntax errors, you should be fine.

You can check for syntax errors by:

ksh -n file

 

>I have reverted back my /etc/profile and .profile as old

 

So you don't have any changes that Bill and I have mentioned that use "if tty -s; then" to condition the tty setting blocks?

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 18 of 21 (770 Views)

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

Hi,

 

>Yes it is in 2 lines

> After reverting to old scripts without semicolon i run teh commands as

 #ksh -n /home/oraprod/9i_profile

It came to # prompt without any error.

 

Now how can we resolve this issue?

Thanks for all your support and really apprecaite it.

 

Regards

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 19 of 21 (765 Views)

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

>Now how can we resolve this issue?

 

What issue?  Your original one?  Bill and I already told you how to do it.

Please use plain text.
Valued Contributor
Syedfurquan
Posts: 345
Registered: ‎09-19-2011
Message 20 of 21 (760 Views)

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

I tried with the provided steps by you and Bill and that also didn't help me.
Issue still persist

Regards
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,398
Registered: ‎03-06-2006
Message 21 of 21 (756 Views)

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

>I tried with the provided steps by you and Bill and that also didn't help me.

 

Are the changes still in place?

 

You basically have to do two things:

1) Find ALL of the stinkin' profile files being executed both at system and user level.

2) Change these files to condition any TTY operations within a "if tty -s; then" block.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation