[techtalk] Re: [ILUG] How a script is called

C. Hennessy Con.Hennessy at airtel-atn.com
Wed Aug 16 10:08:45 EST 2000


Caolan McNamara wrote:
> 
> 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.

Many tools also assume if you give the file name "-" that you mean read from
standard input ( i.e. a pipe ).

Con





More information about the Techtalk mailing list