2012年05月07日 escputil(gutenprint-5.2.7) with EPSON PM-3500C [長年日記]
_ escputil(gutenprint-5.2.7) with EPSON PM-3500C
I installed gutenprint-5.2.7 to control EPSON PM-3500C by using escputil.
How to install
- $ tar xvjf gutenprint-5.2.7.tar.bz2
 - $ cd gutenprint-5.2.7
 - $ ./configure && make
 - $ su
 - # make install && ldconfig
 
How to list supported models
escputil -M
How to show ink status
escputil -s -r /dev/usb/lp0 -m escp2-pm3500c
How to clean nozzle
escputil -c -r /dev/usb/lp0 -m escp2-pm3500c
How to print check pattern
escputil -n -r /dev/usb/lp0 -m escp2-pm3500c
escputil.cgi
Quick hack version B)
#!/usr/bin/perl
#
##use NKF;
#
$Cgipath = "http://Foo.org/cgi-bin/escputil.cgi";
#
#---------------------------------------------------------------------
#
# Get from form
#
read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
@array = split(/&/, $buf);
foreach $i (@array){
  ($key, $val) = split(/=/, $i);
  $val =~ tr/+/ /;
  $val =~ s/%([0-9a-zA-Z][0-9a-zA-Z])/pack("C",hex($1))/eg;
  $val =~ s/\n$//eg;
##  $input{$key} = nkf('-e', $val);
  $input{$key} = $val;
}
#---------------------------------------------------------------------
($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime(time);
#
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=euc-jp\">\n";
print "<title>escputil for EPSON PM-3500C</title>\n";
print "</head>\n";
#
# create form
#
print "<body>\n";
print "<div align=\"center\"><h1>escputil for EPSON PM-3500C</h1></div>\n";
print "<hr>\n";
print "<form action=\"$Cgipath\" method=\"POST\">\n";
print "<input type=\"submit\" value=\"Clean nozzle\" name=\"Clean_nozzle\"><br>\n";
print "<input type=\"submit\" value=\"Print check pattern\" name=\"Print_check_pattern\"><br>\n";
print "<hr>\n";
print "<input type=\"submit\" value=\"Update status\" name=\"Update_status\">\n";
print "<pre>\n";
$status = `/usr/local/bin/escputil -s -r /dev/usb/lp0 -m escp2-pm3500c`;
print $status;
print "</pre>\n";
print "</form>\n";
print "<hr>\n";
#
if ($input{'Clean_nozzle'} eq "Clean nozzle"){
	$status = `/usr/local/bin/escputil -c -r /dev/usb/lp0 -m escp2-pm3500c`;
}
#
if ($input{'Print_check_pattern'} eq "Print check pattern"){
	$status = `/usr/local/bin/escputil -n -r /dev/usb/lp0 -m escp2-pm3500c`;
}
#
if ($input{'Update_status'} eq "Update status"){
	# do nothing
}
#
print "</body>\n";
print "</html>\n";
#---------------------------------------------------------------------
You have to give your http daemon `read/write permission to /dev/usb/lp0'
# vipw -g lp::7:lp,daemon,httpd
[ツッコミを入れる]
2012年05月18日 Issue of require in ruby-1.9.2 or later [長年日記]
_ Issue of require in ruby-1.9.2 or later
ruby-1.9.1 could load foo.rb from current directory by following code.
require "foo"
But ruby-1.9.2(or later) can't load foo.rb by this way for security reason. Now we must write code like following.
#! /usr/bin/ruby -I.
or
require "./foo"
or
$LOAD_PATH.push('.')
require "foo"
[ツッコミを入れる]