Solved

Making Linux look like an HP JetDirect Card

Posted on 2004-09-26
6
575 Views
Last Modified: 2013-12-15
Short - I want to make a printer share on a linux box Fedora2 (i'm willing to use diffrent os) work like an HP JetDirect card does. In other words I want to windows client to send print jobs to an IP address. I think HP JetDirect cards use port 9100

Long story:  My corp accounting dept sends print jobs to my office printer using the HP's JetDIrect cards IP address. We have many jobs that are 500+ pages that just get filled away. I would like to take these print jobs and just save them to a pdf file. I've played and setup a linux box to take a postscript file and convert it to pdf. The box sending the print jobs I think is a SCO unix box, but getting changes to that box is not an option.

Short Summery:  Take a TCP/IP print job ment for a HPLaserJet JetDIrect card and convert it to a pdf and drop it off in a share.

So guys/gals can this be done?
0
Comment
Question by:shook81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12159056
This could be done with a Perl script that starts a server process to listen on port 9100, and then stores every print job received to a file. Once the file is completely written, the server process would then call the Ghostscript to convert the PostScript file to PDF (either directly, or via the ps2pdf script that comes with Ghostscript). You would not be able to give the PDF files any meaningful names. You could try to extract the document name from the DSC header of the PostScript file, but depending on the application that produced the PostScript, you may not find anything useful in the header.

Are you sure that all files that are sent to the printer are PostScript?

One other thing to keep in mind: There are actually two flavours of the JetDirect protocol: One only sends data on port 9100, in the newer one, the printer sends data back to the PC on port 9101. If you can use the first method, the Perl script will work.

How are your Perl skills?
0
 

Author Comment

by:shook81
ID: 12159780
Perl skills = nota  I forgot to add i'm pretty new to linux and trying to learn more about the OS. It sounds like this would be a lot harder then what I had guessed.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12159816
Let me see if I can come up with something. I need some time for this however.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 12165554
OK, it seems to work :-)

Create this file in /etc/xinetd.d and name it jetdirect:

service hp-pdl-datastr
{
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = nobody
        server          = /usr/bin/jetdirect.pl
        disable         = no
}  

Verify that you have an entry named hp-pdl-datastr in /etc/services.

Create a file named /usr/bin/jetdirect.pl with the following content:

#!/usr/bin/perl

$outdir = "/tmp/jetdirect";
#
# write the input data into a temporary file
$file = "/tmp/jetdirect.$$.tmp";
open(FILE, ">$file") || die "Cannot open temporary file $file";
while (<>)
{
        print FILE $_;
}

$date = `date +%Y%m%d%H%M%S%N`;
chomp($date);
$date =~ s/ //g;

$outfile = $outdir."/".$date.".pdf";

system("ps2pdf $file $outfile");
system("/bin/rm -rf $file");

Set the variable $outdir to the directory you want to store the PDF files in (e.g.
$outfile = "/var/spool/jetdirect";

Make sure that the directory exists and is writable for the user listed in the jetdirect file from above (currently set to "nobody").
The document name is set to a timestamp. The script does not currently check if the file name already exists, which is pretty low risk, because the name includes fractions of a second.
You should first find out if this solution works at all for you, once we know that, I'll spend some more time to refine the program.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12199752
Any luck?
0
 

Author Comment

by:shook81
ID: 12279252
sorry for the delay. Some things have come up at the office and I'm having to put this idea on the back burner for now.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question