home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / bin / test_device < prev    next >
Encoding:
Text File  |  2000-03-30  |  639 b   |  22 lines

  1. #! /bin/bash
  2. # test_device sends a short message ($1) to device ($2).
  3. # Timeout is set to $3 sec.
  4. # Exits:   0 doesn't seem to have a problem
  5. #          1 operation has timed out
  6. #          2 problems while writing to $2
  7. #
  8. # Jan Holesovsky <kendy@suse.cz>, 2000
  9. # $Id: test_device,v 1.3 2000/02/25 14:12:24 kendy Exp $
  10.  
  11. EXITCODE=2
  12. trap "EXITCODE=0" 10
  13.  
  14. [ "$2" != "/dev/null" ] && fuser -k $2  # kill all processes using the device
  15.  
  16. ( sleep $3 ) &
  17. SL=$!
  18. ( echo "$1" > $2 && kill -10 $$ ; kill $SL ) &
  19. PR=$!
  20. wait $SL && kill $PR && exit 1    # It cannot finish, it has timed out
  21. exit $EXITCODE                    # How the prining finished?
  22.