General TC > General TC Talk
netcat (nc) acting like a printserver
angryjack:
Hello,
i have PiCore running on a Raspberry 2 and want to use the box to cat like a printserver converting postscript to PCL and sends the output to the target printer. I know that it would be possible to take CUPS instead but i like to do it without.
My idea is that a driver on a PC is sending the postscript output to the RPi2 where a listener is running which picks the file and runs a bash script. The script converts the PS data with ghostscript to PCL and sends the PCL output to the target printer.
The main conversion line is like this:
--- Code: ---gs -sDEVICE=ljet4 -sOutputFile="output.pcl" -dNOPAUSE "input.ps" -c quit
--- End code ---
This is working properly since bmarkus added ghostscript to the PiCore repo...thank him again for this ;)
I found that netcat (nc) should also be able to act as a "file server" like this:
--- Code: ---sudo nc -l -p 9100 > input.ps
--- End code ---
NC is then listening on port 9100 and should redirect the output to input.ps but it does not work for me. I configured a driver on a Windoze system to print to the RPi2 but the print file will stay there in the queue and is not send.
Do i misunderstand something the functionality of netcat or do i only make a mistake ? Probably somebody does have a helpful link for me ?
Rich:
Hi angryjack
After you send the data, does input.ps have anything in it or is it empty? Are you running a firewall on your PI?
--- Quote ---I configured a driver on a Windoze system to print to the RPi2 but the print file will stay there in the queue and is not send.
--- End quote ---
Did you set the printer mode to RAW and the port number to 9100. Could the Windows firewall be blocking it?
--- Quote ---Do i misunderstand something the functionality of netcat or do i only make a mistake ?
--- End quote ---
That looks correct, though you shouldn't need sudo.
--- Quote ---Probably somebody does have a helpful link for me ?
--- End quote ---
You could also do this using inetd found in inetutils-servers.tcz with the example shown here:
http://unix.stackexchange.com/a/203416
angryjack:
seems to be a communication problem between nc and the driver. I start nc and as i initiate a print job via the Windoze driver i get a "no response" message and the driver blocks. As soon as i terminate nc on the RPi2 the driver stops blocking and if i check it the spool file is created on the RPi2. I've checked the file and it is correct. I tried to run the nc process in background with appending a "&" at the end but still the Windoze driver is blocking since i terminate the process on RPi2 side.
I've installed the inetutils_servers but do not know how to configure it as i do only have SSH access and no graphical environment. Basically i would need printing support via JetDirect, port 9100. An example would also be helpful... ;)
angryjack:
I have now installed inetd with the following entries in inetd.conf:
--- Code: ---9100 stream tcp nowait cat > /home/tc/printout.prn
ftp stream tcp nowait root /usr/local/sbin/ftpd ftpd
--- End code ---
FTP deamon is running but i'm not able to print raw data from the WIndoze driver to printout.prn. Any idea ?
P.S: Sorry for double posting but i wasn't able to edit my previous post
Rich:
Hi angryjack
--- Quote ---P.S: Sorry for double posting but i wasn't able to edit my previous post
--- End quote ---
There's a 30 minute time limit for editing posts, and this is an example of why this is a good policy. Anyone checking for new
posts prior to 07:40:50 AM would have seen Reply #2 as originally entered, but be unaware that it was later edited to add
information since editing does not mark the post as being new or unread.
Apparently Windows insists on talking to the printer even though you requested RAW data be sent. Maybe it would make more
sense to tell Windows to print to a file and FTP it to your PI.
Something else you can try:
--- Code: ---9100 stream tcp nowait nc -w 5 -l -p 9100 > input.ps
--- End code ---
When a connection comes in on port 9100, inetd should launch nc. The -w 5 will cause nc to terminate after 5 seconds of
inactivity. Of course if Windows happens to pause for 5 seconds to calculate more printer data or to handle another task, your
file will come up short.
Navigation
[0] Message Index
[#] Next page
Go to full version