seekable stdin
Michael Gale
michael.gale at utilitran.com
Thu Dec 9 21:25:40 CET 2004
Hello,
Thanks for the info .. could I just use the seek command in bash.
According to a `man seek`
doing a `seek STDIN 0 start` should reset STDIN to the beginning for me
.. what do you think ?
Do you see any problems ? Does any one see any problems ?
Michael.
Gyepi SAM wrote:
> On Mon, Dec 06, 2004 at 06:03:06PM -0500, David Relson wrote:
>
>>Reading stdin twice isn't doable, AFAIK. I use "cat > tmp.$$" to create
>>a file and then use that.
>
>
> Actually reading stdin twice *is* doable, if stdin points to a seekable file.
> The filter looked like it was written for postfix, which, as I recall, does
> write the message to disk and dups the filter stdin to the file handle, so
> stdin *should* be seekable, but it's probably not portable to depend on it.
>
> Nonetheless, rewind(3) or seek(3) would do the trick, but the latter should be
> preferred since has a return value.
>
> In a shell script, the easy option is to say:
>
> perl -e 'seek(STDIN, 0, 0) or die "cannot seek stdin. $!\n"'
>
> I have a C version knocking around if perl is too slow ;)
>
> -Gyepi
>
> _______________________________________________
> Bogofilter mailing list
> Bogofilter at bogofilter.org
> http://www.bogofilter.org/mailman/listinfo/bogofilter
>
>
> !DSPAM:41b5367193373727018659!
>
>
--
Michael Gale
Lan Administrator
Utilitran Corp.
Linux: because a PC is a terrible thing to waste !!!
More information about the Bogofilter
mailing list