MATLAB: Am I unable to print from an SGI, HP, or Sun Solaris computer

.lpdillegalMATLABoptionpprintprinting

When I use the BSD form of printing 'lp' in MATLAB, nothing comes out of the printer.

Best Answer

SGI, HP and Solaris 2 users who do not use BSD printing, i.e. 'lpr', need to edit the PRINTOPT.M file (located at $MATLABROOT/toolbox/local/printopt.m) and either uncomment the lines specific to their computer type (in the 'For SGI' or 'For Solaris' sections), or specify the print command explicitly after it is initialized as an empty matrix:
% Intialize options to empty matrices
pcmd = []; dev = [];
% This file automatically defaults to the dev and pcmd shown above
% in the online help text. If you would like to set the dev or pcmd
% default to be different than those shown above, enter it after this
% paragraph. For example, pcmd = 'lpr -s -r -Pfred' would change the
% default for Unix systems to send output to a printer named fred.
% Note that pcmd is ignored by the Windows drivers.
% See PRINT.M for a complete list of available devices.
%---> Put your own changes to the defaults here (if needed)
pcmd= 'lp -c'
If you are using MATLAB 5.3.0, then you will also need to replace the following code fragment starting at line 37, in $MATLABROOT/toolbox/matlab/graphics/@printjob/send.m (where $MATLABROOT is the root MATLAB directory):
%If user specified a printer, add it to the printing command

if isvms
cmdOption = '/QUEUE=';
else
cmdOption = '-P';
end
with the following:
%If user specified a printer, add it to the printing command
if isvms
cmdOption = '/QUEUE=';
else
if notBSD
cmdOption = '-d';
else
cmdOption = '-P';
end
end
If you are specifying a specific printername in your printopt.m file for MATLAB 5.3.0, you will need to make the following change to the @printjob/send.m file as well:
The line that reads
if strcmp( lprcmd, 'lp -c' )
Will need to read
if strcmp(lprcmd,<your print command in single quotes>)
Backup the current versions of these files before making changes to the files.