Example of using the || operator

To send a message to a user using the appropriate utility:

   cat writemail
   #!/bin/sh
   # usage: writemail user message
   echo "$2" |{ write "$1" || mail "$1" ;} 

The user types a command such as:

   writemail sarah 'call me'

The message entered by the user is piped through the command { write "$1" || mail "$1" ; }.

If the the message cannot be sent to the user's terminal (they are not logged on) with the command write "$1" then the message is sent to the user by mail.


[Home] [Search] [Index] This site maintained by system@gantep.edu.tr