Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

evaluating tty command in script

Status
Not open for further replies.

sunsharma

IS-IT--Management
Jul 30, 2005
1
CA
I am trying to install new server and setting up user.

To make life easier I need to tty command to see if is psuedo terminal. If is psuedo terminal i.e. /dev/ttyp*** then i want set up one variable Called OBNAME TO certain value in profie.

I can find value of tty from tty command. However i have been unable to check the ouptput to see if 9 byte is equal to p

Any help will be appreciated. I am trying to avoid setting 50 users again

I have tried cut command, however i can not final result to a variable to evaluate.

I can use if tty >/dev/ttyo or check 9 byte of tty output.

Thanks


 
Something like this ?
case `tty` in /dev/ttyp*) OBNAME="pseudo terminal";; esac

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm not sure this fits what you're trying to do, but an easy way to find out if a script is running against a terminal (as opposed to a cron job or similar) is:

Code:
if [ -t 0 ]
then
        echo This is a terminal session
else
        echo This is a non-interactive session
fi

The [ -t 0] tests whether the stdin (standard input) file descriptor is a terminal.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top