chrisspeck.com

Chris' random ramblings

Resolving Could not get lock /var/lib/dpkg/lock – open (11 Resource temporarily unavailable)

The quick and easy solution is to kill any/all processes which may have a lock, so…

sudo bash
killall aptitude; killall apt-get
killall dpkg; killall frontend
sudo dpkg --configure -a
posted by specky in IT and have No Comments

Using GNU screen in a start-up script

As per this serverfault answer, use the following syntax:

screen -d -m -S [WhateverSessionName] [WhateverCommandsYouWant PlusAnyArgs]
posted by specky in IT and have No Comments

BASH script to photocopy a page and scan to a PDF

I have been using an Epson TX110 for all of my at home printing needs for about three years. While its scanning function is good, I am absolutely sick of the way I need to keep on replacing colour cartridges even though I only ever print in black and white. My colour usage has, in fact, almost entirely been taken up by routing cleaning of the printer heads.

So, rather then spend another dollar on colour cartridges I will never use, I finally bit the bullet and purchased a laser printer.

Being a linux-geek, the first thing I did was connect it to my home server and share it with my laptop and desktop.

The next thing I wanted was the ability to link the scanner function on the Epson TX110 with the Brother laser printer, to be able to quickly photocopy a page. This is amazingly easy with bash and the right tools installed:-

#! /bin/bash
#Find the default printer, or set printer with a literal string e.g. PRINTER="HL2140"
PRINTER=`lpstat -d | awk '{print $NF}'`              
scanimage --mode gr --format tiff --resolution 300 -x 210 -y 290 | lpr -P$PRINTER -oscaling=100

All that remains is to have the ability to scan documents to PDFs…and again, bash and the command line comes to the rescue…you can download my scanpdf.bsh. It is designed for flatbed only scanners. Try running it with --help to see available options. You may click here to view the code.

posted by specky in Downloads,IT and have Comment (1)

Remotely starting X11 apps on other displays

user@laptop:~$ ssh -X user@desktop
...
user@desktop:~$ printenv
...
DISPLAY=localhost:10.0
...
_=/usr/bin/printenv
user@desktop:~$

Take note of the “DISPLAY” variable, this is the local port (on the machine called “desktop”) which is forwarding X11 server commands to the X11 client running on the machine called “laptop”.

user@desktop:~$ export DISPLAY=:0.0
user@desktop:~$ vlc &

This sets the “DISPLAY” variable to the first screen on the desktop, and starts VLC as a background process. For this to work you must be logged into the server with the same user account, and have an X11 client running on the desktop.

user@server:~$ export DISPLAY=localhost:10.0
user@server:~$ gedit &

This sets the “DISPLAY” variable to the laptop, and starts Gedit on the server, but displaying it on the laptop.

posted by specky in IT and have No Comments

m3u playlist copy and tag bash script v1

This is a bash script I wrote which will read an m3u play list, copy all files into a specified directory, and optionally change the “album” and “track number” tag.

I use it as an intermittent step to copy or burn the LastFM play lists which Exaile generates.

The script requires id3tag to tag mp3 files and AtomicParsley to tag m4a files.

Check that the md5 sum matches fb893b406c9eb6379bd0b09ed0e38345.

DO NOT DOWNLOAD IT FROM ANY OTHER SOURCE.

Click here to download.

posted by specky in Downloads,Uncategorized and have No Comments