[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] fax script wizardry



On Friday 26 October 2001 8:27 pm, you wrote:
> I'm trying to find, write or rip off and modify a small shell script
> that's called by inittab that will convert incoming faxes into jpegs.

A script called by inittab?? Ewww :) Sounds more like a daemon you want, to 
me, with some sort of /etc/init.d/faxd type control.

> I can test for the existence of a file, but that's not enough: in the
> first moments that a fax arrives it's incomplete (just the first few
> bytes of the file) and then it grows bigger until it's fully there.

Icky solution (pseudoperl :) -

while (`lsof | grep $filename` ne '') {
	# spin waiting for file
	sleep 5;
}
# file has now been written

My suggestion of Perl is firstly because it's ace, but secondly because you 
may need to run the script suid to do the lsof - hence Perl :) Also, you 
would probably want to run through the file list, like:

while (!$finished) {
	foreach my $file ( [at] filelist) {
		if (`lsof | grep $file` eq '') {
			#process fax
		}
	}
	sleep 5;
}
..kind of thing.

> Any suggestions how to do this? I understand that Hylafax has the
> option to call a script after a fax arrives, but I'm using rungetty -
> which doesn't seem to have this option.

I don't know about rungetty I'm afraid, but the options to look for would be 
some sort of file-locking ability (so you could spin on opening the file), or 
perhaps some trigger-type mechanism.

Cheers,
					Alex.
___________________________________________________________________

Sheffield Linux User's Group - http://www.sheflug.co.uk . 
To unsubscribe from this list send mail to 
shef-lug-request@list.sheflug.org.uk with the word
"unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.