At 08:15 16.08.00 +0100, Conor Daly wrote:
>Anyone know how a bash / csh script can tell if it was called in a pipeline or
>directly from the commandline? I've a script that I want to run either by
>catting a file through a pipe or by invoking from the commandline with the
>file as an arg and I need the script to behave slightly differently in either
>case.
Just check to see if there are any command line arguments which pertain to an
input file. If there's none assume that we're a pipe, that's pretty much
all that
existing apps do.
A dumbo script which optionally takes a single argument which is an input file,
with no argument its a pipe
#!/bin/sh
#count command-line arguments
if [ $# = 0 ]; then
a pipe
else
not a pipe
fi
C.
--
Herein are personal opinions, you'd want to be crazed to consider
these official positions of StarOffice/Sun or even vaguely congruent.
_______________________________________________
techtalk mailing list
[EMAIL PROTECTED]
http://www.linux.org.uk/mailman/listinfo/techtalk