Hello,
I am attempting to print data from a variable directly to a CUPS printer - as opposed to a writing a hard-disk file and then sending it to the printer. The reason is because the file system will eventually be a read-only one.
I have created a file handle for the variable that stores the data and populated it. If I print the contents of $variable it is correct.
To send the data to the printer I am opening a file handle for reading and passing it as an argument to a CUPS printer.
However, I am getting a "No such file or directory" error. Yet, the variable and file handle both exist.
Does CUPS not accept a variable tied to a file handle as a parameter or (more likely) am I doing it improperly?
Thanks in advance.
#!/usr/bin/perl -t use strict; use warnings; use Net::CUPS::Destination; # Define Printer my $cups = Net::CUPS->new() or die $!; my $printer = $cups->getDestination("CITIZEN-CT-S801") or die $!; # Read Data my($variable)=''; open(my $fh, '>', \$variable) or die "Cannot open file for writing: $! +\n"; print $fh "Some data 1\n"; print $fh "Some data 2\n"; print $fh "Some data 3\n"; close($fh); # Print Data open($fh, '<', \$variable) or die "Cannot open file for reading: $!\n" +; if ($printer->printFile($fh, 'jobx')) { print 'Success';} else { my $error = $printer->getError(); if ($error) { print "Printer Error: " . $error . "\n"; } } close($fh); exit;
In reply to CUPS Printing - Using a Variable as a Filename by Wayne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |