Here is new complete pass at the polling. (Actually 2)
Pure shell script.
A perl program (or python, etc) could look for jitter in the line, remember
previous times the devices was seen, etc.

#!/bin/sh
# Poll for a change in devices and run a program on the new device
# This version runs the program on all the existing devices the first time
rm -f oldlist
while :
  # device list
  ls -1 1wire/uncached > newfile
  # find the changes
  grep -N -B -w -I /^S/ oldlist newlist > difflist
  #  Deletions
  grep "^<" difflist | tr -d "< " | xarg -r ex_device_command \{\} 
  #  Additions
  grep "^>" difflist | tr -d "> " | xarg -r new_device_command \{\} 
  # make current device list the old list
  mv -f newlist oldlist
  # pause before polling again
  sleep 1
done

#!/bin/sh
# Poll for a change in devices and run a program on the new device
# This version ignores the existing devices
# existing device list
ls -1 1wire/uncached > oldfile
while :
  # pause before polling again
  sleep 1
  # device list
  ls -1 1wire/uncached > newfile
  # find the changes
  grep -B -w -I /^S/ oldlist newlist > difflist
  #  Deletions
  grep "^<" difflist | tr -d "< " | xarg -r ex_device_command \{\} 
  #  Additions
  grep "^>" difflist | tr -d "> " | xarg -r new_device_command \{\} 
  # make current device list the old list
  mv -f newlist oldlist
done



-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Alfille, Paul
H.,M.D.
Sent: Wed 1/11/2006 7:39 AM
To: owfs-developers@lists.sourceforge.net
Subject: RE: [Owfs-developers] New Device Notification
 
The easiest is to have a script loop through polling the device list.

Something like:
#!/bin/sh
ls 1wire/uncached > oldlist
while :
  sleep 1
  ls 1wire/uncached > newlist
  diff oldlist newlist | grep "^[<>]" > difflist
  # difflist process, perhaps with a simple perlscript
  mv oldlist newlist
done



-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Stuart Poulton
Sent: Wed 1/11/2006 2:46 AM
To: owfs-developers@lists.sourceforge.net
Subject: [Owfs-developers] New Device Notification
 
Hi All,

Is there any way to have OWFS launch an external program on the
connection of a device to the OW Bus ?

Regards

Stuart

-- 
Stuart Poulton <[EMAIL PROTECTED]>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


<<winmail.dat>>

Reply via email to