Pingo$ /usr/local/atalk/bin/getzones | more VLSB LSB-Integrative Biology LSB-Biology Library LSB-Herbaria LSB-UCMP LSB-MVZ Vanishing Packets MIP Barker HallWith the command line option you find out which is your zone:
Pingo$ /usr/local/atalk/bin/getzones -m VLSB Pingo$So my local zone is VLSB, the complete list of all local zones can be obtained using the -l option (in case your printer is not in your zone, you need to know the exact name of the zone).
Pingo$ /usr/local/atalk/bin/nbplkup |more Sun ValleyUs Macintosh:Macintosh IIsi 12398.245:253 Sun ValleyUs Macintosh:Workstation 12398.245:4 IB Instructional Support: Power Macintosh 12398.196:253 IB Instructional Support:Workstation 12398.196:4 centris 660AV: Macintosh 12398.51:253 centris 660AV:Workstation 12398.51:4 Chapin Lab vx - JoeC:Macintosh IIvx 12398.101:253 Chapin Lab vx - JoeC:Workstation 12398.101:4 Pingo Mac Printer:LaserWriter 12398.164:129 Pingo Default Printer:LaserWriter 12398.164:128 Pingo:AFPServer 12398.164:130 Pingo:netatalk 12398.164:4 Pingo:Workstation 12398.164:4 Lucicutia:AFPServer 12398.123:248 Theobald Chapin, III:LaserWriter 12398.73:191If you only want to know specific object types, like LaserWriters, you have to use /usr/local/atalk/bin/nbplkup :LaserWriter. Make sure you include the colon to indicate that you are looking for a type called LaserWriter. The word need not include capital letters, but you are not allowed to omit the spaces. Thus, e.g. to look for Macintosh IIvx you need to put the type name into quotes:
Pingo$ /usr/local/atalk/bin/nbplkup :"Macintosh IIvx" Chapin Lab vx - JoeC:Macintosh IIvx 12398.101:253 Pingo$Ok. To make it short: I want to print from my Linux box to the LaserWriter named Theobald Chapin, III. Before you try to set up printcap for your printspooler, rather make a first check, whether the printer is accessible and your printing comes out as you expect.
status: idleIf not, go back and see whether your AppleTalk really works (maybe the daemon was not started? Check with ps -xa | grep atalkd and ps -xa | grep afpd whether those daemons are present). Since the LaserWriter is expecting PostScript files, you should have a PostScript file handy for a short test. My file's name is test.eps, and I can send it directly to Theobald Chapin, III by invoking the AppleShare print client directly:
/usr/local/atalk/bin/pap -p "Theobald Chapin, III":LaserWriter@VLSB test.epsNote that I included the zone name just to make sure everything is working fine. If your print job comes out (you will get a status message every second or so if somebody else is using the printer at the same moment. Watch how the response comes from your printer and what it does when it starts printing your file). If you encounter any trouble, use aecho to find out about AppleTalk objects in the same way you would do using ping over TCP/IP (hit Ctrl-C to stop aecho):
/usr/local/atalk/bin/aecho "Theobald Chapin, III":LaserWriter@VLSB 14 bytes from 12398.73: aep_seq=0. time=15. ms 14 bytes from 12398.73: aep_seq=1. time=14. ms 14 bytes from 12398.73: aep_seq=2. time=14. ms 14 bytes from 12398.73: aep_seq=3. time=14. ms ----12398.73 AEP Statistics---- 5 packets sent, 4 packets received, 20% packet loss round-trip (ms) min/avg/max = 14/14/15 Pingo$You should only have lost the last packet when you hit Ctrl-C, otherwise something's wrong with your connection.
Thus, to be more clear: you will first set up your printer as a Unix printer accessible for the lpd printer daemon (sections 3.1 through 3.2) and then you make it available for other users in the AppleTalk zone (section 3.3), which is optional, of course.
Many people are confused about the setup for two reasons:
(1) If an AppleTalk printer is already available in the AppleTalk zone,
Mac users can directly connect to it. Thus, there is no need for a print
spooler on a Linux box. However, I am a Linux user and want to have access
to this AppleTalk printer, and thus my description given here does exactly
that: allow Linux users to print on an AppleTalk printer.
(2) If your printer is a local printer attached to the parallel port
of the Linux box (eg. to /dev/lp1), there are some changes for
the printcap file. I will give you an example of a setup with
a local printer which I have not tested myself but was sent to me by another
user. See section 3.4 for this and check out the detailed information given
by Mike Pearson and Bill McGonigle on using
Ghostscript together with Netatalk.
Pingo$ lpr -P lp test.epsthen you can skip this first part of step 3. Otherwise, be root and go into your /etc directory to edit printcap. Use the man page of printcap for all details. I will only describe how to set up the LaserWriter so that it works together with the Linux lpr command. Add an entry for your printer to the printcap file. I have only the LaserWriter defined, and my entry looks like this:
lp|Pingo LaserWriter|Theobald Chapin, III:\ :sd=/usr/spool/theobald:\ :lp=/dev/null:\ :pl#63:pw#85:\ :mx#0:\ :sh:sf:\ :lf=/usr/adm/lpd-errs:\ :if=/usr/local/bin/myif:\ :of=/usr/local/atalk/etc/ofpap:
Pingo$ ls -l drwxrwxr-x 2 root mail 1024 Feb 8 08:46 mail drwxr-xr-x 2 root mail 2048 Feb 8 17:23 mqueue drwxrwxr-x 5 news news 1024 Sep 1 1994 news drwxrwxr-x 2 root lp 1024 Feb 9 13:15 theobaldCreate this directory using mkdir and then set ownership to root and group lp, using
Pingo$ chown root.lp theobaldThen make sure you have the propper privileges using
Pingo$ chmod 775 theobaldThen I created the two files lock and status in this directory:
Pingo$ cd theobald Pingo$ touch lock; chown root.root lock; chmod 004 lock Pingo$ touch status; chown root.root status; chmod 664 statusNow you can define this directory as the spool directory as I did in line 2.
Pingo$ ls -l /usr/local/atalk/etc lrwxrwxrwx 1 root root 3 Feb 8 14:44 ifpap -> psf lrwxrwxrwx 1 root root 3 Feb 8 14:44 ifpaprev -> psf lrwxrwxrwx 1 root root 3 Feb 8 14:44 ofpap -> psf -rwxr-xr-x 1 root root 49299 Feb 8 14:44 papd -rw-r--r-- 1 root root 35 Feb 9 13:48 papd.conf -rwxr-xr-x 1 root root 11395 Feb 8 14:44 psf lrwxrwxrwx 1 root root 3 Feb 8 14:44 tfpap -> psf lrwxrwxrwx 1 root root 3 Feb 8 14:44 tfpaprev -> psf Pingo$So a filter named ifpap will invoke pap, one named ifpaprev will reverse the order of pages and invoke pap. It converts plain text to postscript, so that you do not end up getting an error message. The only filter you really need to install is the of filter:
:of=/usr/local/atalk/etc/ofpap:All other filters are optional (see man psf). However, I left a filter name for plain text,
:if=/usr/local/bin/myif:\where /usr/local/bin/myif is a simple shell script which allows me to make linebreaks in texts, which were written with a program that does line wrapping automatically (e.g. textedit). The psf filter unfortunately does not do any line breaking and ignors the setting for the paper width. I wrote my own filter, linebreak.c which does the job, and put the following two lines in myif (make it executable with chown 755 myif):
#!/bin/sh /usr/local/bin/linebreak $* | /usr/local/atalk/etc/ifpap $*If you set up your text filter in this way, linebreak will only look at the width of your printer (set with pw), while ifpap (psf) only looks at the length. It seems that psf assumes 0 being the first line, so set pl#63 if you want to have 64 lines per page in your output.
If you don't need any line breaking, simply put
:if=/usr/local/atalk/etc/ifpap:\into your printcap file.
Now save your new printcap. If you try to print now, you will find out that it does not work, so read the following paragraph. As I mentioned before, the Unix name of the printer in the printcap file has no relation to the name the printer has in the AppleTalk zone. You need to create a file called .paprc in your printer's spool directory which contains the AppleTalk address of your printer! This is only one line. Note that in this file I did not need to put the printer's name in quotes, but other people report that it only worked with quotes on their system, and others report that it did not work at all with quotes. Thus try it without quotes first:
Pingo$ cat /usr/spool/theobald/.paprc Theobald Chapin, III:LaserWriter@VLSB Pingo$So, now you're ready to go.
If you get an error message like "Turing:LaserWriter@Tech Support": NBP then try it without quotes. It might also be that you only have to put the name before the colon in quotes, like "Theobald Chapin, III":LaserWriter@VLSB in my case. Be creative and try all combinations if you have troubles. I don't know the universial answer to this problem.
For some additional hacks and workarounds with filters see also section 4.3 (known problems).
Pingo$ ps -xa | grep lpd 45 ? SW 0:00 (lpd) 346 pp0 D 0:00 grep lpd Pingo$Try to print a PostScript file and a plain text file to make sure everything works. Probably you have to restart the printer daemon using lpc with the command restart lp, down lp and up lp. Then check the status
lpc> status lp: queuing is enabled printing is enabled no entries no daemon present lpc> lpc> quitNow print your files using
Pingo$ lpr -P lp filenameIf everything is all right, the status file in your spool directory should now contain the most recent status information of your printer :
Pingo$ cat /usr/spool/theobald/status job: Paul; status: busy; source: LocalTalk Pingo$
Pingo$ cat /usr/local/atalk/etc/papd.conf Pingo Mac LaserWriter:\ :pr=lp: Pingo$This means that the (default) printer variable lp is given the name Pingo Mac LaserWriter for AppleShare clients. You will realize that a Mac user now has access to printer Theobald Chapin, III directly and via my Linux box, where the printer's name is Pingo Mac LaserWriter. For me it's important to be able to print directly to this printer, and when working on the Mac the printing via my Linux box seems much faster, since Linux will do the spooling and the printjob disappears almost instantly from my Mac desktop.
If you want to register your printer in a specific zone (not the default zone), you just specify this zone with an @zonename extension in your papd.conf file:
MotorsLab@EEAP:\ :pr=ee3rd:
/etc/princap: lp:lp=/dev/lp1:sd=/usr/spool/lp1:sh
And then in your papd.conf you can define this printer to be available to Mac users: /usr/local/atalk/etc/papd.conf:
HP LJIIIp:\ :pr=lp:\ :pd=/usr/local/atalk/etc/HP_LaserJet_IIIP.ppd:Check out the detailed information given by Mike Pearson and Bill McGonigle on using Ghostscript together with Netatalk if your local printer is not a PostScript printer.
Your Linux box is named castor and you want to print to an ethernet printer whose IP address is named POLLUX. If you do not know the internal name the POLLUX printer knows for itself, it is very likely that it is called lp like a standard printer. Then your /etc/printcap would look like this:
lp|Pollux printer:\ :sd=/usr/spool/pollux:\ :rm=pollux:\ :rp=lp:\ :pl#63:pw#85:\ :mx#0:\ :sh:sf:\ :lf=/usr/adm/lpd-errs:
Feb 12 17:47:52 Pingo ofpap[1443]: starting for ? Feb 12 17:47:52 Pingo ofpap[1443]: sending to pap[1444] Feb 12 17:47:52 Pingo ofpap[1443]: straight text Feb 12 17:47:59 Pingo ofpap[1443]: 1444 done Feb 12 17:47:59 Pingo ofpap[1443]: pausing Feb 12 17:48:01 Pingo ifpap[1447]: starting for ? Feb 12 17:48:01 Pingo ifpap[1447]: sending to pap[1448] Feb 12 17:48:01 Pingo ifpap[1447]: straight text Feb 12 17:48:09 Pingo ifpap[1447]: 1448 done Feb 12 17:48:09 Pingo ofpap[1443]: restarting Feb 12 17:48:09 Pingo ifpap[1447]: done Feb 12 17:48:09 Pingo ofpap[1443]: done Feb 12 18:00:46 Pingo ofpap[1481]: starting for ? Feb 12 18:00:46 Pingo ofpap[1481]: sending to pap[1482] Feb 12 18:00:46 Pingo ofpap[1481]: straight text Feb 12 18:00:51 Pingo ofpap[1481]: 1482 done Feb 12 18:00:51 Pingo ofpap[1481]: pausing Feb 12 18:00:52 Pingo ifpap[1485]: starting for ? Feb 12 18:00:52 Pingo ifpap[1485]: sending to pap[1486] Feb 12 18:00:52 Pingo ifpap[1485]: straight text Feb 12 18:00:57 Pingo ifpap[1485]: 1486 done Feb 12 18:00:57 Pingo ofpap[1481]: restarting Feb 12 18:00:57 Pingo ofpap[1481]: done Feb 12 18:00:57 Pingo ifpap[1485]: doneIf something is wrong, you get a message in /usr/adm/syslog like:
Feb 12 10:04:59 Pingo papd[70]: No such printer: "lp" Feb 12 10:04:59 Pingo papd[70]: printcap problem: "lp"(your default printer variable lp is not defined)
Feb 12 17:02:21 Pingo ofpap[1149]: 1150 died with 1 Feb 12 17:02:21 Pingo lpd[1148]: lp: output filter died (1) Feb 12 17:02:26 Pingo lpd[1148]: lp: Daemon filter 'f' terminated (11) Feb 12 17:04:48 Pingo lpd[1195]: lp: Daemon filter 'f' terminated (11) Feb 12 17:08:03 Pingo lpd[1216]: lp: Daemon filter 'f' terminated (11) Feb 12 17:10:00 Pingo lpd[1228]: cannot execv /usr/local/bin/linebreak|/usr/local/atalk/ifpap Feb 12 17:11:51 Pingo lpd[1244]: /usr/adm/lpd-errs: No such file or directory(/etc/printcap does not accept a pipeline in the definition of if; that's the reason why I used a script file /usr/local/bin/myif. Also I had forgotten to create the file /usr/adm/lpd-errs, which I defined in /etc/printcap.)
unprintable character (0x9a)!This is a problem with psf, the filter used to print. Locate the file psf.c in your netatalk distribution, make it writeable (chmod 644 psf.c). Locate the second line where unprintable character is found. The first occurence (out of 2) should be in line 402 and the second in 496 or so. The second is probably the cause of your problem. Replace the part which reads
if ( !isascii( *p ) || !isprint( *p )) { if ( !literal ) { fprintf( stderr, "unprintable character (0x%x)!\n", (unsigned char)*p ); return( 2 ); /* Toss job */ } printf( "\\%o", (unsigned)*p );with
if ( !isascii( *p ) || !isprint( *p )) { if ( !literal ) { fprintf( stderr, "unprintable character (0x%x) converted to ?!\n", (unsigned char)*p ); /* return( 2 );*/ /* Toss job */ putchar( '?' ); /* Don't toss job! */ } else{ printf( "\\%o", (unsigned)*p ); }Now you type make at the prompt in the netatalk directory (not in the directory where psf.c sits, because make will not know the path to pap in this case!). Then copy the new psf to its propper location (/usr/local/atalk/etc). What this does is only the following: it replaces the unprintable character by an interrogation mark and goes on without tossing the job. Maybe someone has the motivation to write a better psf which converts "unprintable" characters to their printable PostScript equivalent? But pay attention to the copyright of psf, if you do so!
# # Apple LaserPrinter Select 360 on AppleTalk: # lp|Pingo LaserWriter|Theobald Chapin, III:\ :sd=/usr/spool/theobald:\ :lp=/dev/null:\ :pl#61:\ :pw#80:\ :mx#0:\ :sh:\ :sf:\ :lf=/var/adm/lpd-errs:\ :if=/usr/local/bin/myif:\ :of=/usr/local/atalk/etc/ofpap: # # Special setup for plain text files, to convert to PostScript using nenscript # instead of psf (which doesn't process the whole ISO characterset) # text:\ :sd=/usr/spool/textprinter:\ :lp=/dev/null:\ :mx#0:\ :sh:\ :sf:\ :lf=/var/adm/lpd-errs:\ :of=/usr/local/bin/textfilter:The file /usr/local/bin/textfilter is a shell script containing the following lines:
#!/bin/sh /usr/bin/nenscript -P lp -2 -r -T US -i "Werner Eugster"Unfortunately I didn't find a way to preserve the name of the file to be printed, therefore I used the -i option with my name to label the output. You may find more sophisticated setups, using the user name from the Unix environment variable.
In this setup, I get plain text printed on landscape paper (option -r) in two columns (-2) sent to the standard printer lp. To print plain text, I use the command
lpr -P text plain.txtSo, first of all, the printer defined as text converts plain text to PostScript using nenscript (which processes the full ISO character set) and hands it over to the printer defined as lp. Thus, using lpq will show you that the print job turns up in the default (lp) printer queue saying it's coming from stdin, which is ok.
If anyone has some idea how to set things up such that the filename is printed in the header line, I would appreciate this feedback!
#!/bin/sh /usr/local/bin/linebreak $* | /usr/local/atalk/etc/ifpap $*
"At a quick inspection of the output of nbplkup (to see if
there are strange sniffers, viruses lurking around), I saw that the printers
on the network have the same node number as our NT SERVER (which spools
the Windows PCs). This was wrong.
1. NT SERVER is a very bad spooler.
2. It's supposed only to spool the Windows Machines.
3. Even though not instructed to capture all the incoming traffic
to the printers on the network it did.
Solution: Disabled totally the print server for Macintosh on the
NT server. Edited the .paprc file in the spool directory
so it points directly to the printer. Restarted the computer so it will
have a fresh memory."
Modify your /usr/local/bin/myif and pipe everything through awk or any other filter program, that can write an additional line into the pipe after the header line. E.g. I tried the following in my /usr/local/bin/myif:
#!/bin/sh
/usr/local/bin/linebreak $* | awk '{if(NR==1&&$1~"%!"){print;print
"statusdict begin /manualfeed true store end\n";}else{print}}' | /usr/local/atalk/etc/ifpap
$*
(make sure there are no physical linebrakes in line number 2). What this does is: it tells your printer to take the paper from the manual tray. For other trays replace the text in the quotes ("statusdict begin /manualfeed true store end\n") by the appropriate command from the following list.
Tray | PostScript command |
---|---|
Front paper tray | "statusdict begin 0 setpapertray end" |
Rear paper tray | "statusdict begin 1 setpapertray end" |
Manual paper tray | "statusdict begin /manualfeed true store end" |
Tray | PostScript command |
---|---|
Upper output tray | "0 statusdict /setoutputtray get exec" |
Lower output tray | "1 statusdict /setoutputtray get exec" |
However, this only works for input which is already PostScript. If you
want the same for text input which is first converted to PostScript, you
need to modify the psf.c file and produce a new psf filter
(don't forget to really install it in your /usr/local/atalk/etc
directory!). What you have to do is find the line where %%!PS-Adobe-2.0
is printed (approximately line 379, it must be in function textps()).
Add a new program line below this line which says
printf( "statusdict begin /manualfeed true store end\n" );
(again, you may want to replace the text within the quotes with what
is appropriate for your system). Then recompile psf and install
it.
Davis Goodman ended up with the following myif script which finds out whether you want to print to letter size or legal size paper. If it's legal, the PostScript command to select the rear tray is issued, otherwise the default tray is used to take the paper from.
#!/bin/sh bounding=`grep BoundingBox $8 | cut -d" " -f5 ` if [ "$bounding" = "" ]; then /usr/bin/awk '{if(NR==1&&$1~"%!"){print;print "statusdict begin 1 setpapertray end\n";}else{print}}' | /usr/local/atalk/etc/ifpap $* else /usr/local/atalk/etc/ifpap $* fiThis works with Netscape and your own software might produce different values for the BoundingBox. I just included this example by Davis to give you a hint where to start if you want to do similar hacks.
An example comes from Tomas Pospisek who defined a printer name for each tray of the same printer in /etc/printcap. Thus, in any application or in the shell you specify the respective printer name to get stuff printed to paper from a specific tray. Tomas' /etc/printcap looks like this:
# LaserWriter Pro 630 (Default Tray) lp:\ :sd=/usr/spool/lp1:\ :lp=/dev/null:\ :pl#63:pw#85:\ :mx#0:\ :sh:sf:\ :lf=/var/log/lp-errs:\ :if=/usr/lib/atalk/filters/myif:\ :of=/usr/lib/atalk/filters/ofpap: # # LaserWriter Pro 630 (Manual Tray) lpm:\ :sd=/usr/spool/lpm:\ :lp=/dev/null:\ :pl#63:pw#85:\ :mx#0:\ :sh:sf:\ :lf=/var/log/lp-errs:\ :if=/usr/lib/atalk/filters/myif_manual:\ :of=/usr/lib/atalk/filters/ofpap:and the myif_manual filter looks like this:
#!/bin/sh /usr/bin/awk '{if(NR==1&&$1~"%!"){print;print "statusdict begin /manualfeed true store end\n";}else{print}}' | /usr/lib/atalk/filters/ifpap $*
The problem was in our Macintosh's printer driver. A LaserWriter version 7-something. We upgraded it to version 8 (8.3.something) and everything works now. We are printing.
It was hard to detect, because we did all you said in your pages without success, and we thought the problem was in the Linux side, not in the Macintosh one.
I am a Linux system administrator, and know _nothing_ about Mac's. I've also learnt that there are available printer drivers in the www.apple.com page (well, that's not surprising) and if you want to install them you need a program called Installer. This program is withing the printer driver disks, which you have to translate with a program called Disk copy.
I didn't know about the disk-copy program. I just got the drivers and fighted the Mac trying to install them. No way. With the Disk Copy program everything was easiest.
COM domain 34 EDU (USA) 30 US domain (USA) 3 GOV domain USA 5 NET domain 5 ORG domain 1
Australia 2 Austria 5 Belgium 1 Canada 2 France 4 Germany 10 Hongkong 1 Iceland 1 Italy 5 Japan 2 Namibia 1 Netherlands 2 Poland 2 Portugal 2 United Kingdom 2 Spain 2 Switzerland 4