Re: Faxing

2006-01-29 Thread Christian Huldt

24 jan 2006 kl. 11.43 skrev Alan Fry:

As a PS,  [EMAIL PROTECTED] suggested to me [slightly  
condensed]:-



Well, I'd skip the Perl - applescript - Terminal - bash hoopla
why not just use system(efax command line) or just back-ticks.


Indeed that's much better, faster, and cleaner, and works fine.



how about using convert for producing the tiffs?

I think there is a version included in Mac OS X, but since I tend to  
install imagemagick myself at some point I should not  make any  
promises...


Re: Faxing

2006-01-25 Thread Robert Whittle
Thanks for the detailed and useful info provided. When using the efax  
approach described, is there any record available anywhere that tells  
you whether or not the fax was successfully sent or not? Options to  
retry if the number is busy ?


thanks


On 23 Jan 2006, at 12:09, Alan Fry wrote:

I was intrigued by the original question and have done some  
experiments on this G4 running Mac OS X 10.4.4.


Firstly I set the machine up so as to be able to send faxes from  
applications using the Mac OS Print-PDF-Fax PDF… built in  
facility. I have a broadband connection (ethernet modem) so it was  
necessary to add a serial modem to dial up the remote fax machine's  
number. A USB modem left over from the old internet dial-up days  
seemed promising.


There is on http://www.apple.com/support/ a very clear concise  
document Mac OS X 10.4: Adding a Bluetooth fax device. Although a  
USB modem is not quite the same animal as a Bluetooth modem, the  
recipe for the one works for the other. There is no point  
rehearsing the 12 steps set out in that document here: anyone  
interested should download the Apple document.


Having done this, Print-PDF-Fax PDF was found to work perfectly  
with a number of applications, for instance BBEdit. This  
established that the machine was capable of sending faxes. However  
it does not settle the question of how to send faxes from within a  
Perl script. If the document's application is scriptable a fax  
might be sent by an AS to work the 'Print' facility, and that AS  
could be dispatched from Perl. But that is by no means a good  
general solution to the problem.


However 'efax' does offer a more general solution. There are, I  
think, various ways to call Unix from Perl. I have tended to write  
a shell script for the Unix function, calling that from the Perl  
script by 'tell application Terminal -- do script() -- end tell'.  
So the first step was to get 'efax' working from the terminal.


By default 'efax' expects to find '/dev/cu.modem', which on this  
machine does not exist. However 'ls /dev/' revealed (amongst a heap  
of stuff) an entry 'cu.usbmodem08141'. Using this in place of the  
default results in a command line:

efax -d /dev/cu.modem08141 -t [remote fax number] file.tif
That worked fine. (I am lucky that my ISP, demon, provides me with  
a fax number for incoming faxes which it then e-mails to me, which  
I can send faxes to myself for test purposes. Otherwise, I suppose,  
you would need a local good friend with a fax machine in order to  
do the experiments…)


The question then arose how to obtain a faxable version of the  
document in question. This is most complex part of the problem  
simply because of the huge number of possible document formats. In  
my own small world I restrict the range to Postscript and PDF  
documents. Postscript is useful because firstly one can very easily  
output '.ps' files from Perl (for instance the perl script 'pod2ps'  
does this) and secondly within Mac OS X every application can save  
its document as a PDF file. Hence, On the whole, I need only deal  
with '.ps' and '.pdf' files.


The question then arises as to how to convert these formats to G3  
compressed '.tiff' files required by 'efax'. Now there is a  
companion to 'efax' by the name of 'efix' which can do this but I  
must confess so far I have been unable to make it work. However it  
appears that it is effectively a front end for ghostscript, and  
therefore it seems to me more sensible to use 'gs' directly. Even  
if one opts to use 'efix' ghostscript must be installed. The mantra  
for converting a file to a faxable format is:
	gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -dTextAlphabits=4 - 
dGraphicsAlphaBits=4 -sOutputFile=outfile infile
Obviously one has complete freedom of choice about the outfile name  
and extension, but 'gs' determines the infile format from the  
infile extension I believe. By this means '.ps', '.pdf', '.txt' and  
a whole heap of graphics formats can be converted to fax format.  
Again, from Perl a shell script can be invoked by a AppleScript  
call to the Terminal.


As Bill Stephenson says below there is a front end for both 'efax'  
and 'efix' going under the name 'fax'. The command 'fax make file'  
will produce a fax format file with the same name as file with . 
001, .002 etc. appended. It uses 'efix', which in turn uses 'gs'. I  
can see no advantage in this. Indeed there are snags with 'fax':  
for instance it expects a US letter page size and truncates an A4  
postscript page. There appears to be no way of controlling page  
size. Similarly the commmand 'fax send file' fails because it uses  
'efax' with all default settings, including the default serial  
modem. There appears to be no way of overriding the 'efax' defaults  
from 'fax'.


I have not tried (yet) the suggestion of piping a file to 'lpr' --  
certainly the serial modem appears in 'lpinfo' -- so it might well  
work. However I think 

Re: Faxing

2006-01-25 Thread Alan Fry


On 25 Jan 2006, at 10:32, Robert Whittle wrote:

Thanks for the detailed and useful info provided. When using the  
efax approach described, is there any record available anywhere  
that tells you whether or not the fax was successfully sent or not?  
Options to retry if the number is busy ?


There are return codes from 'efax' which tell you what transpired:

0   The fax was successfully sent or received.

	1	The dialed number was busy or the modem device was in use. Try  
again later.


	2 	Something failed (e.g. file not found or disk full). Don’t retry.  
Check the session log for more

details.

	3 	Modem protocol error. The program did not receive the expected  
response from the modem.
		The modem may not have been properly initialized, the correct -o  
options were not used, or a

bug report may be in order. Check the session log for more 
details.

	4 	The modem is not responding. Operator attention is required.  
Check that the modem is turned

on and connected to the correct port.

5   The program was terminated by a signal.

I guess one would have to handle the return codes appropriately in  
the perl script.


This, and much more information on the capabilities of 'efax' are all  
to be found in the 'man pages': type 'man efax' into the Terminal  
window.


HTH



Re: Faxing

2006-01-24 Thread Alan Fry


On 23 Jan 2006, at 17:34, Bill Stephenson wrote:


On Jan 23, 2006, at 5:09 AM, Alan Fry wrote:

I was intrigued by the original question and have done some  
experiments on this G4 running Mac OS X 10.4.4.


snip


Wow, thanks for sharing what you've learned! Admittedly, I haven't  
had much time to play with this since I asked that question but  
your reply puts me way ahead of where I was then. I'd also like to  
thank everyone else that replied. If I get my Fax the House  
script finished I'll post a copy of it.


As a PS,  [EMAIL PROTECTED] suggested to me [slightly condensed]:-


Well, I'd skip the Perl - applescript - Terminal - bash hoopla
why not just use system(efax command line) or just back-ticks.


Indeed that's much better, faster, and cleaner, and works fine.

Many thanks for your kind remarks. I look forward to seeing Fax the  
House in due course.


Alan


Re: Faxing

2006-01-23 Thread Alan Fry
I was intrigued by the original question and have done some  
experiments on this G4 running Mac OS X 10.4.4.


Firstly I set the machine up so as to be able to send faxes from  
applications using the Mac OS Print-PDF-Fax PDF… built in facility.  
I have a broadband connection (ethernet modem) so it was necessary to  
add a serial modem to dial up the remote fax machine's number. A USB  
modem left over from the old internet dial-up days seemed promising.


There is on http://www.apple.com/support/ a very clear concise  
document Mac OS X 10.4: Adding a Bluetooth fax device. Although a  
USB modem is not quite the same animal as a Bluetooth modem, the  
recipe for the one works for the other. There is no point rehearsing  
the 12 steps set out in that document here: anyone interested should  
download the Apple document.


Having done this, Print-PDF-Fax PDF was found to work perfectly  
with a number of applications, for instance BBEdit. This established  
that the machine was capable of sending faxes. However it does not  
settle the question of how to send faxes from within a Perl script.  
If the document's application is scriptable a fax might be sent by an  
AS to work the 'Print' facility, and that AS could be dispatched from  
Perl. But that is by no means a good general solution to the problem.


However 'efax' does offer a more general solution. There are, I  
think, various ways to call Unix from Perl. I have tended to write a  
shell script for the Unix function, calling that from the Perl script  
by 'tell application Terminal -- do script() -- end tell'. So the  
first step was to get 'efax' working from the terminal.


By default 'efax' expects to find '/dev/cu.modem', which on this  
machine does not exist. However 'ls /dev/' revealed (amongst a heap  
of stuff) an entry 'cu.usbmodem08141'. Using this in place of the  
default results in a command line:

efax -d /dev/cu.modem08141 -t [remote fax number] file.tif
That worked fine. (I am lucky that my ISP, demon, provides me with a  
fax number for incoming faxes which it then e-mails to me, which I  
can send faxes to myself for test purposes. Otherwise, I suppose, you  
would need a local good friend with a fax machine in order to do the  
experiments…)


The question then arose how to obtain a faxable version of the  
document in question. This is most complex part of the problem simply  
because of the huge number of possible document formats. In my own  
small world I restrict the range to Postscript and PDF documents.  
Postscript is useful because firstly one can very easily output '.ps'  
files from Perl (for instance the perl script 'pod2ps' does this) and  
secondly within Mac OS X every application can save its document as a  
PDF file. Hence, On the whole, I need only deal with '.ps' and '.pdf'  
files.


The question then arises as to how to convert these formats to G3  
compressed '.tiff' files required by 'efax'. Now there is a companion  
to 'efax' by the name of 'efix' which can do this but I must confess  
so far I have been unable to make it work. However it appears that it  
is effectively a front end for ghostscript, and therefore it seems to  
me more sensible to use 'gs' directly. Even if one opts to use 'efix'  
ghostscript must be installed. The mantra for converting a file to a  
faxable format is:
	gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -dTextAlphabits=4 - 
dGraphicsAlphaBits=4 -sOutputFile=outfile infile
Obviously one has complete freedom of choice about the outfile name  
and extension, but 'gs' determines the infile format from the infile  
extension I believe. By this means '.ps', '.pdf', '.txt' and a whole  
heap of graphics formats can be converted to fax format. Again, from  
Perl a shell script can be invoked by a AppleScript call to the  
Terminal.


As Bill Stephenson says below there is a front end for both 'efax'  
and 'efix' going under the name 'fax'. The command 'fax make file'  
will produce a fax format file with the same name as file with .001, . 
002 etc. appended. It uses 'efix', which in turn uses 'gs'. I can see  
no advantage in this. Indeed there are snags with 'fax': for instance  
it expects a US letter page size and truncates an A4 postscript page.  
There appears to be no way of controlling page size. Similarly the  
commmand 'fax send file' fails because it uses 'efax' with all  
default settings, including the default serial modem. There appears  
to be no way of overriding the 'efax' defaults from 'fax'.


I have not tried (yet) the suggestion of piping a file to 'lpr' --  
certainly the serial modem appears in 'lpinfo' -- so it might well  
work. However I think everything you might want to do from within  
Perl can be done quite simply by firstly using 'gs' to convert the  
file to faxable format and sending the fax by 'efax'. In both cases a  
suitable shell script can be invoked from within a perl script by an  
AppleScript 'do script' command.


I hope this may be 

Re: Faxing

2006-01-23 Thread Bill Stephenson

On Jan 23, 2006, at 5:09 AM, Alan Fry wrote:

I was intrigued by the original question and have done some 
experiments on this G4 running Mac OS X 10.4.4.


snip


Wow, thanks for sharing what you've learned! Admittedly, I haven't had 
much time to play with this since I asked that question but your reply 
puts me way ahead of where I was then. I'd also like to thank everyone 
else that replied. If I get my Fax the House script finished I'll 
post a copy of it.


Kindest Regards,

--
Bill Stephenson



Re: Faxing

2006-01-18 Thread Robert Whittle
I managed to get perl to send faxes using the 'fax' front-end  
program, but never satisfactorily. I had to use root user to send  
faxes and I never managed to send any faxes that has graphics in the.  
In the end I installed PageSender, which has examples of sending  
faxes via AppleScript, and I called the AppleScript from perl. I know  
that sounds a  lot more round-about but it had a lot of advantages  
for me. I could send HTML files, correctly formated, and there is a  
record kept which you can view in the GUI of all faxes send, or not.


If you do get something working, I'd  be very interested to know how  
you got it done


Robert Whittle


On 18 Jan 2006, at 08:29, Dominic Dunlop wrote:


On 2006–01–17, at 20:29, Bill Stephenson wrote:
Is there a way to fax a document using the built-in Mac OSX (10.3)  
fax feature with perl?


Well, the command-line program underlying the facility is efax.  
There's also a simplified front-end program, fax. You could try  
calling either of those with system() or whatever. Alternatively,  
CUPS makes the fax modem visible as a printer once it's configured  
-- run  lpinfo -v  and you should see it listed. This means that  
you should be able simply to pipe the stuff you want to fax to lpr.  
The trick would be to work out what option you need to put on the  
command line in order to get the number dialled, and acceptable  
formats for the data. (Text is probably OK. Beyond that, I've no  
idea.)


Not that I've tried either possibility myself.


I want to write a script that faxes selected members of congress  
my humble opinions ;)


A laudable aim.
--
Dominic Dunlop





Re: Faxing

2006-01-18 Thread Adrian Hosey
On Wed, 18 Jan 2006, Robert Whittle wrote:

: I managed to get perl to send faxes using the 'fax' front-end program, but
: never satisfactorily. I had to use root user to send faxes and I never managed
: to send any faxes that has graphics in the. In the end I installed PageSender,
: which has examples of sending faxes via AppleScript, and I called the
: AppleScript from perl. I know that sounds a  lot more round-about but it had a
: lot of advantages for me.


Also, anything that supports AppleScript can be driven directly from Perl
using Mac::Glue.

-- 
...while the Japanese are unable to duplicate the American film [market] they
 can destroy it by this video cassette recorder. - Jack Valenti, 1982


Re: Faxing

2006-01-18 Thread Doug McNutt
At 13:29 -0600 1/17/06, Bill Stephenson wrote:
I want to write a script that faxes selected members of congress my humble 
opinions ;)

You can send e-mail from perl and that leads to two options:

1) Send the email to efax (sp) where it can be converted to FAX and sent  for a 
fee.

2) Don't vote for representatives who steadfastly refuse to publish an e-mail 
address. I know, they will need a clerk to read it but that's true for the FAX 
too. Joel Hefley; are you listening?
-- 

-- Love your country. But don't trust its government. --


Re: Faxing

2006-01-18 Thread Joseph Alotta

Hi Doug,

I like the idea of efax.  It seems good but costs $13/month.   That  
is a little high for me considering I send or receive about 5 faxes a  
year.  I wonder if there is another place that only charges when you  
do something?


On Jan 18, 2006, at 11:51 AM, Doug McNutt wrote:


At 13:29 -0600 1/17/06, Bill Stephenson wrote:
I want to write a script that faxes selected members of congress  
my humble opinions ;)


You can send e-mail from perl and that leads to two options:

1) Send the email to efax (sp) where it can be converted to FAX and  
sent  for a fee.


2) Don't vote for representatives who steadfastly refuse to publish  
an e-mail address. I know, they will need a clerk to read it but  
that's true for the FAX too. Joel Hefley; are you listening.


I was under the impression that all US representatives get an email  
address automatically assigned to them, whether they use it or not.






-- Love your country. But don't trust its government. --