Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Monday, 10 December 2018

Filter failed error for Kyocera printers in Linux is caused by a BUG in the device driver

I recently got a new Kyocera FS-1025MFP unit and the print jobs would stop if there are Chinese characters in the job title. The OS is Ubuntu 16.04. Specifically, the error message was either "filter failed" or "filter crashed". Upon checking the CUPS error messages, I discovered that this was due to an error signal 6 returned by the "rastertokpsl" program shipped with the Kyocera driver.

To correct this problem:

1. Download, and install the Kyocera driver by running install.sh as root. This will copy the printer's PPD file to /usr/share/cups/model/Kyocera/ and the rastertokpsl program to /usr/lib/cups/filter/.

2. Create a wrapper for rastertokpsl by:
sudo nano /usr/lib/cups/filter/rastertokpsl-fixed
and then insert the following text:
#!/bin/bash
jobname=$(echo $3 | egrep -o '[[:alnum:]]' | tr -d '\n' | tail -c 20)
path=/usr/lib/cups/filter
$path/rastertokpsl "$1" "$2" "$jobname" "$4" "$5"
3. Make sure that the wrapper has execution permission:
sudo chmod a+x /usr/lib/cups/filter/rastertokpsl-fixed
4. Edit the PPD file specific to your printer model as found in /usr/share/cups/model/Kyocera/. For instance, mine is an FS-1025MFP and the file name is Kyocera_FS-1025MFPGDI.ppd. The only modification that should be made is the cupsFilter line (line 55 in my case):
Find:
*cupsFilter: "application/vnd.cups-raster 0 /usr/lib/cups/filter/rastertokpsl"
and replace the line with:
*cupsFilter: "application/vnd.cups-raster 0 /usr/lib/cups/filter/rastertokpsl-fixed"
The above steps should fix the problem. Alternatively, you may edit the PPD file shipped with the installation package and create the rastertokpsl-fixed wrapper for the installation files, and add the wrapper into install.sh so that you can be able to install the corrected driver with a single command.

I think the problem also affects FS-1040, FS-1060DN, FS-1020MFP, FS-1120MFP and FS-1125MFP, since they are using the same rastertokpsl program.

Monday, 27 November 2017

Setting up port forwarding on Ubuntu 16.04

Here we demonstrate how to set up port forwarding on a VPS with Ubuntu 16.04, so that we can use this VPS as an Internet traffic forwarding service. This setup is useful when the route between the source and the destination IPs is bad, but the intermediate VPS has good connections to both the source and the destination.

First, set the net.ipv4.ip_forward=1 flag in the /etc/sysctl.conf file with vi, and use the following command to make it effective immediately:
sysctl -p
Next, say we want to use port 50000 to forward both TCP and UDP traffic to 168.10.0.1:40000. We use the following iptables commands:
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 50000 -j DNAT --to-destination 168.10.0.1:40000
iptables -t nat -A PREROUTING -p udp -m udp --dport 50000 -j DNAT --to-destination 168.10.0.1:40000
iptables -t nat -A POSTROUTING -d 168.10.0.1/32 -p tcp -m tcp --dport 40000 -j SNAT --to-source 172.10.0.1
iptables -t nat -A POSTROUTING -d 168.10.0.1/32 -p udp -m udp --dport 40000 -j SNAT --to-source 172.10.0.1
In the command above, 172.10.0.1 is the private IP of the intermediate VPS. We can use the following command to check if we set up the NAT table correctly:
iptables -L -n -t nat
Finally, to make the iptables settings persistent, install:
apt-get install iptables-persistent
To save any additional changes to the NAT table, run:
netfilter-persistent save

Thursday, 3 October 2013

Installing JDK on Ubuntu

This is an example of how to install JDK on Ubuntu. I wrote this when I was using JDK 7 with Ubuntu 10.04 -- so you may want to check Oracle's website for the latest version.

1. Download one of the following files:
http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz (for 32-bit)
http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz (for 64-bit)

2. Decompress the .tar.gz file.

3. Move the JDK files to /usr/lib/jvm/jdk1.7.0 or somewhere else as appropriate.

4. Run from bash shell:
sudo vim /etc/environment
You will see something like
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
Change the file to something like (also change the installation path if needed)
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0/bin"
CLASSPATH=.:/usr/lib/jvm/jdk1.7.0/lib
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
And then reload .bashrc file:
source ~/.bashrc
5. Run the following commands from bash shell:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0/bin/javap 300
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.7.0/bin/javadoc 300
Installation is now complete. Run the following command from bash shell for a test:
java -version