Sharing Open File Current Offset? (Looking for example of applications)

Peter da Silva peter at ficc.ferranti.com
Wed Aug 22 03:55:06 AEST 1990


In article <6011 at chorus.fr>, francois at chorus.fr (Francois Armand) writes:
> 	I am looking for some _real_ _uses_ of current offset sharing
> by real applications running on any flavor of UNIX systems.

Here's one from a script I use in mail handling:

{
  echo "An error occurred on `net lname` while attempting to forward mail."
  echo "It was not possible to forward the mail to $SYS for further handling."
  echo "(it is possible that $SYS was down, or temporarily off the network,"
  echo " so please try again in a few minutes)"
  echo ""
  echo "Your mail was not delivered to $USERS"
  if [ -s $TMP ]
  then
    echo ""
    echo "The following messages were returned from the delivery program:"
    echo "=========="
    cat $TMP
    echo "=========="
  fi
  echo ""
  echo "Here are the contents of the lost mail:"
  echo "=========="
  cat
} > /tmp/err$$

> I have never seen any program using this property!

Now you have. It's used all over in shell scripts. In fact, in Version 6
UNIX this is how control structures in shell scripts were implemented:
"if" and so on were loadable programs, that seeked on the open file
descriptor for the script looking for labels.
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.   'U`
peter at ferranti.com



More information about the Comp.unix.questions mailing list