Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!samsung!brutus.cs.uiuc.edu!wuarchive!decwrl!ucbvax!hplabs!hplabsb!quan From: quan@hplabsb.HP.COM (Suu Quan) Newsgroups: comp.unix.questions,hp.unix Subject: how do you watch for an incoming file Keywords: file directory unix Message-ID: <5506@hplabsb.HP.COM> Date: 28 Nov 89 21:10:51 GMT Organization: Corporate Manufacturing Factory Systems, Palo Alto, CA Lines: 28 How do I write a C-program or shell script that will watch for the presence of a new file in a certain directory. Scenario : I expect a file to be sent to me -name possibly unknown- to a directory (callit /application/inputfile/). Since I do not know when it will arrive (ftp, rcp ... does not matter), I want to be notified of its presence as soon as possible but not burn any cpu in the mean time. I know how to write a shell script will a loop and a sleep a la : cd /application/inputfile/ while (1) do sleep($some) if [ $(/bin/ls) ] # assume ksh then echo there is something in here else ; fi done. But I would prefer a C-program or a script using a blocking command Any help is appreciated -- Suu Quan (TELNET/415) 857-3594 quan@hpcmfs.corp.HP.COM HEWLETT-PACKARD, Corp Manuf Factory Systems quan@hpcmfs Palo Alto, CA 94304 suu quan /HP0080/04