[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell script reading stdin?



On Sat, Jun 10, 2000 at 10:54:32PM -0400, Mike Werner wrote:
> I'm trying to write a shell script that will noninteractively accept
> a chunk of text on standard input, but haven't been able to figure out
> how to go about doing so.  What I'm trying to do is write a script that
> will get called by an exim filter.  Accroding to the exim docs, when a
> script is called by the filter, the script is run and the message is
> passed on the standard input.
> 
> I tried having a look through the bash man page - I found references on
> redirecting stdin and stdout and stderr, all of which I already knew.
> What I couldn't find was *any* mention of was how to *use* stdin from
> within a shell script.  Anyone here ever done anything like this?

What about /dev/stdin?

    cat <<EOF > foo.scr
    #!/bin/bash
    echo "Hi, this is a shell script"
    cat /dev/stdin
    EOF
    chmod +x foo.scr
    echo "This is standard input" | ./foo.scr

...is that what you want?

-- 
Karsten M. Self <kmself@ix.netcom.com>         http://www.netcom.com/~kmself
  Evangelist, Opensales, Inc.                       http://www.opensales.org
   What part of "Gestalt" don't you understand?      Debian GNU/Linux rocks!
     http://gestalt-system.sourceforge.net/      K5: http://www.kuro5hin.org
GPG fingerprint: F932 8B25 5FDD 2528 D595  DC61 3847 889F 55F2 B9B0

Attachment: pgpRt8_8KYcdj.pgp
Description: PGP signature


Reply to: