Client(3pm)
π Client(3pm) β User Contributed Perl Documentation π
okay bestie, pull up a chair, because we're about to talk about Fax::Hylafax::Client, and honestly? it's giving iconic. π
β¨ NAME β¨
Fax::Hylafax::Client β a Simple HylaFAX client. yes, that's literally the whole name. short. sweet. slay. π
πΈ SYNOPSIS πΈ
use Fax::Hylafax::Client qw(sendfax);
my $fax = sendfax(
dialstring => '5555555555',
docfile => '/usr/home/test/document.ps',
);
π¦ DESCRIPTION π¦
so this is a simple Perl client for the HylaFAX fax server (www.hylafax.org). π«Ά
here's the part that lowkey makes it the main character: it talks to the server directly through an FTP-like protocol, which means you do not need any HylaFAX software components installed on the client machine. none. zero. nada. it just shows up and does the thing. β¨
π MAIN METHODS AND ATTRIBUTES π
sendfax π
this method sends a fax job to the server. it returns a Client::Queued object. π
it takes a hash of the following attributes:
hostβ Hostname of the server. Defaults tolocalhost. [OPTIONAL]portβ Connection port of the server. Defaults to4559. [OPTIONAL]userβ Username of the client. Defaults toanonymous. [MAY BE REQUIRED]passwordβ Password of the client. Defaults toanonymous. [MAY BE REQUIRED]dialstringβ Destination string (number) to dial. [REQUIRED]docfileβ Full pathname of the document file. This attribute takes a single filename (scalar) or a reference to an array of filenames. Document files must be in one of the native HylaFAX formats, i.e. Plain Text, PostScript, TIFF Class F, or PDF. [REQUIRED unless you usepolloption]coverfileβ Full pathname of the cover page file. All notes aboutdocfileapply, except it only takes one filename as scalar. [OPTIONAL]notifyaddrβ E-mail address of the person to be notified about the status of the job. Defaults touser@hostname. [OPTIONAL]notifyβ Controls the email notification messages from the server. Possible values:noneβ notify if error only,doneβ notify when done,requeueβ notify if job is re-queued,done+requeue. Defaults tonone. [OPTIONAL]passiveβ If set to1connects to server in PASSIVE mode. Defaults to0. [OPTIONAL]sendtimeβ Time when the fax should be sent. Possible values:nowor date in formatYYYYMMDDHHMM. It looks like this value must be in GMT time zone. Defaults tonow. [OPTIONAL]lasttimeβ Kill the job if not successfully sent after this much time. FormatDDHHSS. Defaults to000259(3 hours). [OPTIONAL]maxdialsβ The maximum number of times to dial the phone. Defaults to12. [OPTIONAL]maxtriesβ The maximum number of times to retry sending a job once connection is established. Defaults to3. [OPTIONAL]pagewidthβ Set the transmitted page width in millimeters. Defaults to216(Letter size). [OPTIONAL]pagelengthβ Set the transmitted page length in millimeters. Defaults to279(Letter size). [OPTIONAL]vresβ Set the vertical resolution in lines/inch to use when transmitting facsimile. High resolution equals to196, low resolution equals to98. Defaults to196. [OPTIONAL]chopthresholdβ The amount of white space, in inches, that must be present at the bottom of a page before HylaFAX will attempt to truncate the page transmission. Defaults to3. [OPTIONAL]schedpriβ The scheduling priority to assign to the job. Defaults to127(Normal). [OPTIONAL]pollβ Try to poll a fax from remote machine. Value can be an empty string orselector [passwd]. [OPTIONAL]
sendpage π
Sends SNPP page job to the server. Returns Client::Queued object. Takes a hash of the following attributes:
hostβ Same as insendfax.portβ Connection port of the server. Defaults to444. [OPTIONAL]userβ Same as insendfax.passwordβ Same as insendfax.pinβ Pager Identification Number as defined inpagermapfile on the server. [REQUIRED]messageβ Text message to be sent (alfa-numeric pagers only). [OPTIONAL]notifyaddrβ Same as insendfax.notifyβ Same as insendfax.passiveβ Same as insendfax.maxdialsβ Same as insendfax.maxtriesβ Same as insendfax.levelβ Priority level to assign to the job. Values can be0-7(0 being the highest). Defaults to1(Normal). [OPTIONAL]
faxinfo π
Request the status of a particular job. Returns Client::Instant object. Can take only the number of the job as an attribute or a hash of the following attributes:
hostβ Same as insendfax.portβ Same as insendfax.userβ Same as insendfax.passwordβ Same as insendfax.jobidβ ID of the job. [REQUIRED]passiveβ Same as insendfax.
faxrm π
Remove job from the server (kill it). Returns Client::Instant object. Behaves like and has the same attributes as faxinfo.
faxstat π
Request statistics from the server. Returns Client::Instant object. Takes a hash of the following attributes:
hostβ Same as insendfax.portβ Same as insendfax.userβ Same as insendfax.passwordβ Same as insendfax.passiveβ Same as insendfax.infoβ If set to1displays additional status information for the server. This status typically has information such as the HylaFAX version, the physical location of the server machine, and an administrative contact for the server. Defaults to0. [OPTIONAL]filesβ If set to1displays the status of document files located in the docq directory on the server machine. Thefilefmtattribute defines the content and format of information reported with this option. Defaults to0. [OPTIONAL]queueβ If set to1displays the status of jobs in the send queue on the server machine. Thejobjmtattribute defines the content and format of information reported with this option. Defaults to0. [OPTIONAL]doneβ If set to1displays the status of all jobs that have completed; i.e. those jobs located in the doneq directory on the server machine. Thejobfmtattribute defines the content and format of information reported with this option. Defaults to0. [OPTIONAL]receivedβ If set to1displays the receive queue status. Thercvfmtattribute defines the content and format of information reported with this option. Defaults to0. [OPTIONAL]filefmtβ The format string to use when returning file status information. Seefaxstatman pages for details. [OPTIONAL]jobfmtβ The format string to use when returning job status information. Seefaxstatman pages for details. [OPTIONAL]rcvfmtβ The format string to use when returning status information about received jobs. Seefaxstatman pages for details. [OPTIONAL]
π METHODS AND ATTRIBUTES OF ALL Client::* OBJECTS π
successβ Returns true if the task was accepted. This only means the task request was successfully processed by the server. This does not always mean the task itself was successfully completed. Usefaxinfoto check for that. β οΈ (fr fr, don't get it twisted)traceβ Returns responses from the last communication with the server. Useful for debugging. π
π METHODS AND ATTRIBUTES OF Client::Queued OBJECTS ONLY π
faxinfoβ Returns the status of the job at this particular moment. β°faxrmβ Kills the job. πjobidβ Returns the ID assigned to the job by the server. π·οΈ
π METHODS AND ATTRIBUTES OF Client::Instant OBJECTS ONLY π
contentβ Returns content returned by the server. π¬
β GLOBAL VARIABLES β
$Fax::Hylafax::Client::Hostβ Specifies hostname of the server. Used in place ofhostattribute.$Fax::Hylafax::Client::Portβ Specifies connection port of the server. Used in place ofportattribute.$Fax::Hylafax::Client::Userβ Username of the client. Used in place ofuserattribute.$Fax::Hylafax::Client::Passwordβ Password of the client. Used in place ofpasswordattribute.$Fax::Hylafax::Client::Passiveβ Specifies if PASSIVE connections should be used. Used in place ofpassiveattribute.$Fax::Hylafax::Client::NotifyAddrβ E-mail address where server notifications will be sent. Used in place ofnotifyaddrattribute.
β¨ EXAMPLES β¨
Okay bestie, this is the part where it all comes together. Real code, real vibes. π
Sending a fax π
use Fax::Hylafax::Client qw(sendfax);
my $fax = sendfax(
host => 'remote.host.name',
dialstring => '14151234567',
docfile => '/usr/home/test/document.ps',
coverfile => '/usr/home/test/cover.ps',
notifyaddr => 'test@user.com',
);
if ($fax->success)
{
print "We are OK";
}
else
{
print $fax->trace;
}
See how we just... call it? Iconic. Send the fax, check success, and if it's giving failure energy, dump trace so you can see what the server was actually saying. π¦
Misc. examples π
use Fax::Hylafax::Client qw(sendfax sendpage faxstat faxinfo faxrm);
$Fax::Hylafax::Client::Host = 'remote.server.hostname';
$Fax::Hylafax::Client::User = 'faxuser';
$Fax::Hylafax::Client::Password = '*password*';
$Fax::Hylafax::Client::NotifyAddr = 'client@address.com';
my $fax = sendfax(
dialstring => '14151234567',
docfile => [
'/usr/home/test/document1.ps',
'/usr/home/test/document2.ps',
],
);
my $task_succeded = $fax->success ? "YES" : "NO";
my $server_responses = $fax->trace;
my $job_id = $fax->jobid;
my $current_job_status = $fax->faxinfo;
my $server_stats = faxstat( info => 1, active => 1 )->content;
if (faxinfo($job_id)->content ne 'DONE')
{
print "We're not done yet";
$fax->faxrm;
# or
faxrm($job_id);
# or
my $task = faxrm(
host => 'remote.server.hostname',
user => 'faxuser',
password => '*password*',
jobid => $job_id,
);
print $task->success ? "We killed it!" : "Server didn't like it: " . $task->trace;
}
my $other_server_task = faxstats( host => 'other.server.host', user => 'bob', password => 'whatever' );
if ($other_server_task->success)
{
print $other_server_task->content;
}
else
{
print "Doh! We failed to get stats from the server: ", $other_server_task->trace;
}
my $page = sendpage(
pin => 'bob',
message => 'Time to wake up',
);
my $task_succeded = $page->success ? "YES" : "NO";
Bestie, let's break this down because there's a LOT happening and it's all delicious. π
- First we set the global variables β
$Fax::Hylafax::Client::Host,$Fax::Hylafax::Client::User,$Fax::Hylafax::Client::Password, and$Fax::Hylafax::Client::NotifyAddrβ so every call after that just inherits them. No cap, it's a whole mood. πΈ - Then
sendfaxwithdialstringand adocfilethat's an arrayref of two documents. Multiple files, one job. We love efficiency. β¨ $fax->successgives you a yes/no,$fax->tracegives you the server's receipts,$fax->jobidgives you the job id, and$fax->faxinfogives you the current job status. π«Άfaxstat( info => 1, active => 1 )->contentpulls the server stats, and iffaxinfo($job_id)->contentisn't'DONE', we're still waiting β so we bail out withfaxrm. Three flavours of removal are shown: the method$fax->faxrm, the plainfaxrm($job_id), and the fully-loadedfaxrm( host => ..., user => ..., password => ..., jobid => ... ). Pick your fighter. π₯- Then
faxstats(note the plural β it's in the example exactly like this, we don't editorialize π) hits a totally different server with its ownhost,user, andpassword, and printscontenton success or thetraceon failure. - Finally
sendpagewith apinand amessage, and we checksuccessagain. Time to wake up, bob. π
Heads up bestie: the example uses$task_succeded(with anein the middle) and callsfaxstatsβ that's how it appears in the original, so copy it as-is if you're copy-pasting. π
π AUTHOR π
Alex Rak arak@cpan.org
π COPYRIGHT π
Copyright (c) 2003,2006 Alex Rak. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
- HylaFAX man pages <http://www.hylafax.org/>
And that's the whole page, bestie β go forth and fax. π¦β¨
This one's from perl v5.26.2, dated 2018-08-20 β so it's giving vintage, but the fax energy is timeless. Periodt. π
π¦ where this page comes from
- debian bookworm: libfax-hylafax-client-perl 1.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libfax-hylafax-client-perl 1.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libfax-hylafax-client-perl 1.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libfax-hylafax-client-perl 1.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms