[Tipz] Is the program being run interactively?
Ian Langworth
bass at ccs.neu.edu
Sun May 9 12:04:50 EDT 2004
If your script needs to determine if it's being run
interactively or it's being piped to, here's the snippet:
if [ -t 0 ]; then
echo "interactive"
else
echo "pipe"
fi
Or, in Perl,
if ( -t STDIN ) {
print "interactive\n";
}
else {
print "pipe\n";
}
The same applies to STDOUT and whatnot.
--
Ian Langworth
Project Guerrilla
Northeastern University
College of Computer and Information Science
More information about the Tipz
mailing list