File: print_file.pl

package info (click to toggle)
libnet-cups-perl 0.64-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 4,171; pascal: 3,212; ansic: 64; makefile: 3
file content (30 lines) | stat: -rwxr-xr-x 582 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl

##
## This is a *simple* example with minimal error checking of how to 
## print a file.
##

use strict;
use warnings;

use Net::CUPS;
use Net::CUPS::Destination;

{
	die( "Please give me the name of a file to print!\n" ) if ( @ARGV < 1 );
	
	my $filename = $ARGV[0];

	my $cups = Net::CUPS->new();

	my $dest = $cups->getDestination();

	die( "You don't have a default printer setup!\n" ) if( !defined( $dest ) );

	print "I am attempting to print $filename to " . $dest->getName() . ".\n";

	$dest->printFile( $filename, "Net::CUPS Test Print!" );

	exit( 0 );
}