[cups-devel] .1.3.6.1.4.1.2699.1.2.1.2.1.1.3.1 responses

Jeff Sadowski jeff.sadowski at gmail.com
Fri Mar 27 14:43:42 PDT 2015


I know this is CUPS development mailing list but I think this is the
best place to ask this. I'm hoping some of the developers of CUPS
might know how to get Windows to select a good driver for my program.

Is there a good network printer response to
.1.3.6.1.4.1.2699.1.2.1.2.1.1.3.1  that would select a pre-installed
postscript print driver for windows that you guys know of?
Or maybe a network printer driver that is easy to convert to a PDF

I wrote a network printer interface for my non network printer.

My interface is simply socat

/usr/bin/socat -s TCP4-LISTEN:9100,bind=192.168.16.253,pktinfo,fork
EXEC:/scripts/jetdirect.sh,nofork

that I run from systemd

my jetdirect.sh is a simple script that interprets the input from port
9100 and makes a pdf out of it.

#!/bin/bash
file=/home/print/script_print-$$-`date +"%Y-%m-%d-%H-%M-%S"`
log=/home/print/pdfprint.log
cat > ${file}.ps
echo OK
copies=`grep "%%BeginNonPPDFeature: NumCopies" ${file}.ps|awk '{print $3+0}'`
if [ "${copies}" = "" ];then
 copies=`grep "%RBINumCopies:" ${file}.ps |awk '{print $2+0}'`
fi
if [ "${copies}" = "" ];then
copies=1
fi
echo received from ${SOCAT_PEERADDR} >> ${log}
echo converting ${file}.ps to ${file}.pdf >> ${log}
ps2pdf ${file}.ps ${file}.pdf
echo  rm -f ${file}.ps >> ${log}
rm -f ${file}.ps
echo print ${copies} copies of ${file}.pdf >> ${log}
if [ "`lsusb |grep 04f9:01ab`" != "" ];then
 lp -d MFC240C ${file}.pdf -o uncollate -n $copies
 echo  rm -f ${file}.pdf >> ${log}
 rm -f ${file}.pdf
else
 echo "The printer was not on. To print run the following command." >> ${log}
 echo "lp -d MFC240C ${file}.pdf -o uncollate -n $copies;rm -f
${file}.pdf" >> ${log}
fi

I wrote a php script for snmpd that answers windows'
.1.3.6.1.4.1.2699.1.2.1.2.1.1.3.1 request

my snmpd.conf looks like so

rocommunity  public
pass .1.3.6.1 /bin/php /scripts/passprinter.php

and

passprinter.php looks like so

<?php
$PLACE=".1.3.6.1";
$values=array();
$values[$PLACE.'.2.1.1.1.0']=array('string','Postscript Interceptor');
$values[$PLACE.'.2.1.43.5.1.1.1.1']=array('counter','0');
$values[$PLACE.'.2.1.43.13.4.1.9.1.1']=array('integer','5');
$values[$PLACE.'.2.1.43.13.4.1.9.1.2']=array('integer','3');
$values[$PLACE.'.2.1.43.13.4.1.9.1.3']=array('integer','4');
$values[$PLACE.'.4.1.2699.1.2.1.1.1.0']=array('string','en-US');
$values[$PLACE.'.4.1.2699.1.2.1.1.2.0']=array('gauge','1');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.2.1']=array('string','PS-Intercept');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.3.1']=array('string','MFG:Samsung;CMD:SPL,FAX,FWV,PIC,EXT;MDL:SCX-3400
Series;CLS:PRINTER;MODE:FAX3,SCN,SPL3,R000105;');
//$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.3.1']=array('string','MFG:Generic;MDL:Color
Postcript;');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.4.1']=array('gauge','3');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.5.1']=array('integer','1');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.6.1']=array('integer','1');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.7.1']=array('string','public');
$values[$PLACE.'.4.1.2699.1.2.1.2.1.1.8.1']=array('integer','1');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.2.1.1']=array('integer','1');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.2.1.2']=array('integer','1');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.2.1.3']=array('integer','1');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.4.1.2']=array('string','lp');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.5.1.1']=array('integer','11');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.5.1.2']=array('integer','8');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.5.1.3']=array('integer','44');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.6.1.1']=array('integer','9100');
$values[$PLACE.'.4.1.2699.1.2.1.3.1.1.9.1.2']=array('integer','1');
function OID_comp_less($OID1,$OID2)
{global $PLACE;
// return $OID1 < $OID2;
 if($OID1==$OID2){return false;}
 $OID2_parts=explode('.',substr($OID2,strlen($PLACE)+1));
 $OID1_parts=explode('.',substr($OID1,strlen($PLACE)+1));
 foreach($OID2_parts as $part=>$value)
 {if(!isset($OID1_parts[$part])){return true;}
  if(intval($value)==intval($OID1_parts[$part])){continue;}
  if(intval($value)>intval($OID1_parts[$part])){return true;}
  //echo $value.'<'.$OID1_parts[$part]."\n";
  if(intval($value)<intval($OID1_parts[$part])){return false;}
 }
 return false;
}
if(count($argv)>2 && $argv[1]=='-s'){echo $argv[2]."\n"; exit();}
if(count($argv)>2 && substr($argv[2],0,strlen($PLACE))==$PLACE)
{if($argv[1]=='-n')
 {$RET='';
  foreach($values as $k=>$v)
  {//echo 'next OID:'.$k."\n";
   if(OID_comp_less($argv[2],$k)){$RET=$k;break;}
  }
  if($RET==''){exit();}
 }
 else
 {$RET=$argv[2];
 }
 if(isset($values[$RET]))
 {echo $RET."\n";
  echo $values[$RET][0]."\n";
  echo $values[$RET][1]."\n";
 }
 else
 {file_put_contents('/tmp/passprinter.err.log',$RET."\n",FILE_APPEND);
}}
?>



More information about the cups-devel mailing list