Replacement script for "line -t"


 AIX 3.2.5


 Customer is trying to write a script that will prompt for
 input from standard in, wait for 30 seconds, and then proceed
 with the script if no input has been received during this time.
 The customer has an OEM machine that allows him to use the -t
 flag with the line command.  This flag is not found on AIX, and 
 unfortunately, AIX can not do this via a command.  However,
 with the following scripts, you can accomplish the desired

 Please note that the following scripts are examples only.  They
 are provided as is and IBM does not provide technical support
 for these scripts.


 \# mytrap -- prompts the user for a value and prints the
 \# value entered, or, if no value was entered for 30
 \# seconds, prints a default value.
 trap ':' 30

 j=DEFAULT_VALUE                \# set up default value
 echo "Please enter a value: "  \# prompt for input
 touch pid.$$                   \# create a temporary file, pid.$$
 alarm $$ 30 &                  \# set an alarm for 30 seconds
 read i                         \# read stdin
 rm -f pid.$$                   \# remove the temporary file
 i=${i:=$j}                     \# if i=NULL then set to default
 echo "value = $i"              \# print out results


 \# alarm - Sends a SIGUSR1 (signal 30) to the specified 
 \# process after the specified amount of time has expired.
 \# Syntax: alarm PID SECONDS
 sleep $2               \# sleep for specified \# of seconds
 if [ -f pid.$1 ]       \# send signal only if pid.$1 exists
   kill -30 $1          \# send SIGUSR1 to process

 To run the above example, enter "mytrap".  The second script is
 called from the first one.  The alarm script waits 30 seconds.  
 After 30 seconds, the alarm script sends a signal 30 (SIGUSR1) 
 to mytrap if teh pid.$1 file exists. SIGUSR1 interrupts the read,
 causing i to be set to null.  The line "i=${i:=$j}" causes i to
 be set to the default value if it is null; otherwise, i retains
 its current value.  The last line of mytrap prints out the value
 of i.

Support Line: Replacement script for "line -t" ITEM: AE9620L
Dated: January 1995 Category: N/A
This HTML file was generated 99/06/24~13:30:28
Comments or suggestions? Contact us