> -----Original Message-----
> From: Aglipay, Recelyn [mailto:recelyn.agli...@ehmc.com] 
> Sent: Thursday, March 12, 2009 07:19
> To: Wagner, David --- Senior Programmer Analyst --- CFS; 
> beginners@perl.org
> Subject: RE: Network Printing using a Perl Script
> 
> Hi Dave,
> 
> I'm using a third party application to call the perl script.  This
> application only allows for subroutines to be written since 
> the app also
> uses some perl.  So the code below is all I have.  My goal was to open
> the directory which contains .dat files.  Print all of them to the
> printer.
> 
> I've tried using different syntax for the open command but 
> all I get is
> the message I've created within the code "Unable to open the printer".
> I had thought that my line of code for the open would do the printing?
> Is there another command I would need to use?
> I know there is a print command but I thought that would only 
> be used if
> you want to print text that you define?  Can you use it to 
> print a file?
> 
> Thanks for your help.
> 
> -Recelyn
> 
> -----Original Message-----
> From: Wagner, David --- Senior Programmer Analyst --- CFS
> [mailto:david.wag...@fedex.com] 
> Sent: Wednesday, March 11, 2009 5:48 PM
> To: Aglipay, Recelyn; beginners@perl.org
> Subject: RE: Network Printing using a Perl Script
> 
>  -----Original Message-----
> > From: Aglipay, Recelyn [mailto:recelyn.agli...@ehmc.com] 
> > Sent: Wednesday, March 11, 2009 15:35
> > To: beginners@perl.org
> > Subject: Network Printing using a Perl Script
> > 
> > Hello everyone,
> > 
> >  
> > 
> > I'm a beginner and having some issues with a Perl Script I 
> had written
> > for work.
> > 
> > I am trying to print to a network label printer.  I've 
> > verified that the
> > printer is working on its own.
> > 
> > But when I try to print to it using Perl nothing happens.
> >
Here is an untested portion of code to read the directory, read a file,
print what is in the file
and loop through the directory until end of directory.
                my $port = "9100";
                my $printer1 = q[\\10.10.10.10\Zebra LP2824];
                my $directory = q[D:/TEST/TDS/EdPtLabels];
                my $FileToRead;
                opendir(DIRECTORY, $directory) || die "Couldn't Open the
Directory!: $!"; 
                #
                # you have opened directory, but you need to read the
directory until done
                while ( 1 ) {
                    $FileToRead = readdir(DIRECTORY);
                    last if ( ! defined $FileToRead);
                    open(FILETOREAD, q[<] . $FileToRead) || die "Unable
to open input $FileToRead; $!";
                    open(OUTPUT_PRINTER, q[>] .  $printer1 . q[\] .
$port) || die "Unable to open the printer!: $!";
                    #
                    #  Here you need to write to the OUTPUT_PRINTER
                    # depending on what is in the file. If it is set to
print, then something as easy as
                    #
                        while ( <FILETOREAD> ) {
                            print OUTPUT_PRINTER $_;
                         }
                    close(FILETOREAD);
                    close(OUTPUT_PRINTER);
                    #
                    # unsure if you want to print success after each
file printed or what
                    # here is going to be printed after each file
                    print LOG_FILE
"\n--------------------------------------------------------------\n"
                    print LOG_FILE "The label was printed
successfully\n";
                    print LOG_FILE
"\n--------------------------------------------------------------\n";
                 } # end of loop ro read thru directory
                close(DIRECTORY); 
> >  
> > 
> > Here is a copy of my code.  I get the message "The label was printed
> > successfully" in my log but nothing ever printed.
> > 
> >  
> > 
> > return 1;
> > 
> >  
> > 
> > sub PRINT_LABEL
> > 
> >  
> > 
> > {
> > 
> >                 my $port = "9100";
> > 
> >                 my $printer1 = "\\10.10.10.10\Zebra LP2824";
>       With double quotes, you are not getting waht you think. When
> slashes(\) and double quotes are involved, then need to double the
> slashes or use single quotes.
> > 
> >                 my $directory = "D:/TEST/TDS/EdPtLabels";         
> > 
> >  
> > 
> >                 opendir(DIRECTORY, $directory) || die 
> > "Couldn't Open the
> > Directory!"; 
> > 
> >                 open(OUTPUT_PRINTER, "> $printer1\$port") ||
>       Again the double quotes and the \ are not doing what yiou think.
> 
> > die "Unable
> > to open the printer!";
> > 
>       Either you have code missing or you think something is happening
> by the opendi. At this point, you have an open directory and attempted
> open output, but no where do I see you doing the printing of the
> file(s).
> 
>       Is there code missing or is this it?
>          If you have any questions and/or problems, please 
> let me know.
>          Thanks.
>  
> Wags ;)
> David R. Wagner
> Senior Programmer Analyst
> FedEx Freight
> 1.719.484.2097 TEL
> 1.719.484.2419 FAX
> 1.408.623.5963 Cell
> http://fedex.com/us 
> 
> 
> >                 
> > 
> >                 print LOG_FILE
> > 
> "\n--------------------------------------------------------------\n";
> > 
> >                 print LOG_FILE "The label was printed 
> successfully\n";
> > 
> >                 print LOG_FILE
> > 
> "\n--------------------------------------------------------------\n";
> > 
> >  
> > 
> >                 closedir (DIRECTORY);    
> > 
> >                 close (OUTPUT_PRINTER);
> > 
> >  
> > 
> > }
> > 
> >  
> > 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
> 
> CONFIDENTIALITY NOTICE: This email communication and any 
> files attached may contain private, confidential, or legally 
> privileged information intended for the sole use of the 
> designated and/or duly authorized recipient(s). If you are 
> not the intended recipient or have received this email in 
> error, please notify the sender immediately by email and 
> permanently delete all copies of this email including all 
> attachments without reading them. If you are the intended 
> recipient, secure the contents in a manner that conforms to 
> all applicable state and/or federal requirements related to 
> privacy and confidentiality of such information.
> 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to