03-10-2006
test -t is used to test if a file descriptor is pointing to a tty device:
if [ -t 0 ] ; then
echo this will go to a tty
fi
It is one of the few things that a double bracket test cannot do. fuser and lsof are the only programs that can do this. If you don't have lsof, get it. Or live without the capability.
10 More Discussions You Might Find Interesting
1. Programming
Hi everyone ,
Is there any predefined C function that tests whether an input is string or an integer?
Thank's in advance :) (3 Replies)
Discussion started by: qqq
3 Replies
2. UNIX for Advanced & Expert Users
Hello everyone,
I' m currently working on an open source project and I'm looking for people willing to test the software on various platforms so that we'll be able to publish a compatibility list.
The project is called CorneliOS, it's a webOS and web application framework, and it has been... (0 Replies)
Discussion started by: joskirps
0 Replies
3. Shell Programming and Scripting
Hello All,
Can somebody help me with this script. I have an output file with a list of servers ips and ports. I need to be able to run this script to list all the server ips in the outfile and find out if the port is open or not.
#!/bin/sh
IFS=#;for i in $(cat portTest);
do
# check... (2 Replies)
Discussion started by: liketheshell
2 Replies
4. Programming
Hi everybody,
I need to check in C program whether a given login is known on the system. Is there any system function that could do this ?
So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by... (2 Replies)
Discussion started by: xavier054
2 Replies
5. UNIX for Advanced & Expert Users
Hi,
I found this:
https://www.unix.com/unix-advanced-expert-users/27318-how-see-function-shell.html
which indicates I can use typeset -f to list the functions.
But it also lists the contents of the functions. Is there a
lighter weight way to see what is defined? Is there an
internal... (5 Replies)
Discussion started by: duderonomy
5 Replies
6. Shell Programming and Scripting
Help Please perl Gurus,
I am trying to add ungrouped passengers in a group and I creating a script however it fails on first step only I tried all the options it returns following error.
syntax error at junki line 4, near "open "
Execution of junki aborted due to compilation errors. ... (2 Replies)
Discussion started by: dynamax
2 Replies
7. Shell Programming and Scripting
I have found a code some where, which looks like
if (test $value)
then
<do something>
fi
I am not understanding what is test doing here. I have seen test with !,-eq, -e etc.
But, the above appears to be a new one to me.
Can anyone please expalin me. (4 Replies)
Discussion started by: mady135
4 Replies
8. Shell Programming and Scripting
i am writing the following snippet and cannot figure out why the variable measType remains 0. it should be 1
I also tried "\#analog" and '\#analog' in the test statement and it still doesn't work. What is going on?
bash$ measType=0
bash$ read line < 2iconfig.ini
bash$ echo $line
#analog... (4 Replies)
Discussion started by: oahmad
4 Replies
9. Shell Programming and Scripting
Hello all, just a quick little part of code i'm writing to check if the file i'm writing too in my automatic process is not being written too manually.
#!/bin/bash
FUSER=$(/sbin/fuser -s /toto.tmp >/dev/null 2>&1)
LSOF=$(/usr/sbin/lsof | grep -q "toto.tmp")
PGREP=$(pgrep -f "toto.tmp" >... (6 Replies)
Discussion started by: maverick72
6 Replies
10. Shell Programming and Scripting
Hello everyone,
I have written simple script below to check if ip is added to interface
#!/usr/local/bin/bash
IFCONFIG="/sbin/ifconfig"
SERVICE="/usr/sbin/service"
IP="79.137.X.X"
GREP=$(${IFCONFIG} | grep ${IP})
ip_quantity_check () {
echo ${GREP} | wc -l
}
if ];... (2 Replies)
Discussion started by: bryn1u
2 Replies
tty(1) User Commands tty(1)
NAME
tty - return user's terminal name
SYNOPSIS
tty [-l] [-s]
DESCRIPTION
The tty utility writes to the standard output the name of the terminal that is open as standard input. The name that is used is equivalent
to the string that would be returned by the ttyname(3C) function.
OPTIONS
The following options are supported:
-l Prints the synchronous line number to which the user's terminal is connected, if it is on an active synchronous line.
-s Inhibits printing of the terminal path name, allowing one to test just the exit status.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of tty: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Standard input is a terminal.
1 Standard input is not a terminal.
>1 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
isatty(3C), ttyname(3C), attributes(5), environ(5), standards(5)
DIAGNOSTICS
not on an active synchronous line
The standard input is not a synchronous terminal and -l is specified.
not a tty
The standard input is not a terminal and -s is not specified.
NOTES
The -s option is useful only if the exit status is wanted. It does not rely on the ability to form a valid path name. Portable applications
should use test -t.
SunOS 5.10 1 Feb 1995 tty(1)