pantz.org banner
lpq lp cannot chdir to spooling directory
Posted on 03-10-2013 18:45:47 UTC | Updated on 03-10-2013 18:48:03 UTC
Section: /software/cups/ | Permanent Link

Had a friend send me this little gem that had them perplexed for a while. Eventually they figured it out.

The Problem

On one our Ubuntu servers lpq was reporting it could not see our printers. CUPs was already configured with all the printers. We verified CUPSd daemon was started and we could print to all printers using the web interface at http://127.0.0.1:631 on the local machine.

The problem is the command line interface tool "lpq" and "lprm" were throwing the following errors:

user@ubuntu# lpq
lpq: lp: cannot chdir to spooling directory
user@ubuntu# lprm
lprm: lp: cannot chdir to spooling directory

The confusing part is lpr, lpq, lprm and lpstat are all part of the "lpr" Ubuntu package. You can verify your install using "dpkg --get-selections | grep lpr". What we needed was the exact same lpr, lpq, lprm and lpstat binaries which are made to work with CUPSd.

The Fix

lpr is a stand alone package. lpr only works with the lp print system, not with cups. To replace "lpr" we have to install "cups-bsd" to work with cupsd.
user@ubuntu# sudo apt-get install cups-bsd

The following extra packages will be installed:
  libfile-copy-recursive-perl update-inetd
The following packages will be REMOVED:
  lpr
The following NEW packages will be installed:
  cups-bsd libfile-copy-recursive-perl update-inetd
0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded.

As you can see the old "lpr" package was removed and cups-bsd was installed. cups-bsd replaces the binaries lpr, lpq, lprm and lpstat and works with CUPSd. Now using lpq works as expected with the previously configured cups printers.

user@ubuntu:~# lpq
printer is ready
no entries

Del.icio.us! | Digg Me! | Reddit!

Related stories

YouTube html5 buffering issues
Posted on 03-03-2013 19:07:33 UTC | Updated on 03-03-2013 19:44:27 UTC
Section: /software/html/ | Permanent Link

Let me start by saying I love loved YouTube's html5 trial. It was so great to be able to watch videos without using crappy Adobe flash. Being able to run videos at 1.5x and 2x was just amazing. I started my html5 trial in the middle of last year sometime. It was going fine until about 3 or 4 weeks ago.

The issue

I started having buffering issues with all my html5 videos. They would start to play and then would constantly stop to buffer for more data. Watching the bandwidth of my workstation it was going at a max of 60K/sec down. That was not cutting it at all. Usually YouTube gives you a big burst of data in the beginning of the video and then throttles it back to a few hundred KB a second.

Who's issue is this?

I started checking my download speeds at speed testing sites and it was working fine. Checked my firewall and it looked fine. I could not figure it out. About a week later I'm telling someone at work talking about my issue. He says "That's funny I'm having the same issue lately". Another guy pipes up and says he was having that issue also, but he had fixed it.

The fix

He tells me he finally narrowed it down to the html5 test beta. Once he dropped out of that the videos started playing with flash again and everything was back to normal. I told him I would try that when I got home. Sure enough turning off the html5 trial fixed the issue. I could hardly believe it so I decided to do a test.

The test

I used Calomel.org's fantastic YouTube download script for my test. I picked a video and downloaded it without being in the html5 trial. It downloaded an 85Meg video in about 5 seconds. I go back in to the browser and turn on html5. Then download the same video again. I'm back to being capped at ~65K/sec. It was taking forever to download. I killed that and turned off html5 again. Video downloaded in about 10 seconds this time. Much much faster than being in the trial. One other thing I checked was this cool YouTube speed test page. It said my avg bandwidth for the last month was 14Mbps. So I know it was not my connection to them that is the issue.

Conclusions

By using this wget script it eliminated the browser and flash as being the fix. Just by being marked as being in the html5 trial was the issue. It seems there is some issue with YouTube and html5 right now for a few friends and myself. If I had to venture a guess at the issue, I would say they have code that will throttle html5 people differently from everyone else and they have an issue with that code right now. I do hope it will be fixed. I know it worked fine for months before this, so it should be possible to fix.

Del.icio.us! | Digg Me! | Reddit!

Related stories

Recording sound from your web browser using Linux
Posted on 11-27-2012 18:25:59 UTC | Updated on 12-05-2012 01:19:22 UTC
Section: /software/alsa/ | Permanent Link

My goal here is to record any audio coming from my browser. I looked a bit and could not find a Firefox add-on or Chrome extension that could do this. Some looked like they might, but they looked shady and gave me an icky feeling. There was one called Freecorder, but it was all up in Microsoft's business. This being Linux I assumed there had to be a better way and there was.

For the impatient (quick version)

  1. sudo apt-get install flac gnome-media pavucontrol lame
  2. Start programs PulseAudio Volume Control (pavucontrol) and Sound Recorder (gnome-sound-recorder).
  3. Start you audio. Go to Sound Recorder. Click the record button (red circle).
  4. Switch to PulseAudio Volume Control. In "Record Stream from" select your audio device.
  5. When ready switch back to Sound Recorder and click the stop button. Then click the save button to save the recording.

See below for more detailed information on this process and about encoding files after recording.

What you need

  1. You need an Ubuntu distribution or another Linux distro that has the applications below. I'm using Xubuntu 12.04 for this demo.
  2. Internet access to install the packages.
  3. A working sound system with PulseAudio. Most Ubuntu distros already use this for the sound system.
  4. The following packages installed: sudo apt-get install flac gnome-media pavucontrol lame. This will install the packages on a system with apt-get (Ubuntu/Debian).

Getting things started for recording

First thing first is open your browser and find some type of audio and start playing it. Keep it playing while we do the rest of this. Next, in your Application menu find the "PulseAudio Volume Control" program and start it. Mine was in the Multimedia menu. Then find something called "Sound Recorder". That was in the Multimedia menu as well. If you can't find them you can try to start them from the command line with pavucontrol & and gnome-sound-recorder &. If they are installed this will start and background both programs.

Starting the recording

Make sure your sound is still playing and you can hear it in your speakers. Go to the Sound Recorder program and make sure "Recording from input:" is set to "Master". Then in the "Record as:" menu select how you want to save your audio. If you want the best sound select "CD quality, Lossless". This will record audio as a flac file. The worst quality is at the bottom of the menu and it is "Voice Lossy". That is mono 22k and sounds like crap, but is much smaller. This would be good for just talking. Now, click the big red circle to start the recording. This will begin writing a file to the /tmp dir.

Switch to the PulseAudio Volume Control" window. Click on the "Recording" tab. You should see an area called "Record Stream from:". Click the drop down box next to this and select your audio device you want to record. Usually this says something like "Monitor of ..." where ... is the name of your Linux alsa audio device. You can look at the "Playback:" tab to see your playback device name. Try many different ones until you hit one that starts the bar bouncing a little below the selection box. This bouncing bar (level) shows you are receiving sound. You might need to fiddle with the "Show:" drop down at the bottom if this bar does now show up. Try the 3 different settings and see if that helps.

Finishing the recording

Now that the recording is going you should check the bottom of the Sound Recorder and make sure the level bar is bouncing or is filled with color (you have it up to high). If that is the case you can just let it go as long as you want. Once your ready to stop your recording switch back to the Sound Recorder window and click the red square button. We have not yet saved the file so click the icon for the disk with the arrow. It will ask you where to save your file and what to call it. Give it a name and click the "Save" button. Depending on how big the file is this might take some time. It will even look like the window is locked up. Just give it a good amount of time to save the file.

Converting recordings to mp3

This step is optional, but most people will want to do this if you did not select mp3 "Record as" option in Sound Recorder. That setting is a low 128bit recording so depending on your sound source you might want to record in a lossless codec like flac. I suggest recording in flac if you have the disk space, because you can always downgrade the mp3 encode from there if you want. My example will use FLAC files recorded by Sound Recorder.

# Decode to wav format. Decoded file will have same filename with .wav extension
flac -d recording.flac
# Encode decoded .wav file to 192k mp3 
lame --preset cbr 192 recording.wav recording.mp3

Suggestions/Notes

Recording from the command line

After doing all of the above with GUI's I thought the geeker people might want to know how to do this from the command line. Since the desktop Ubuntu system is using PulseAudio for the sound server we can tap into that using the same method that Sound Recorder does by using PulseAudio recorder program (parec). The problem is finding the monitor device name from the PulseAudio server. Luckily someone has already done the work for us. Thanks to www.outflux.net we have a script that will find the device and even start the recording for us. See the script below. I modified it so you can give it a stop time and it will cut off your recording in X amount of seconds. Without the time given it just records until you hit Ctrl-C. I have also modified it to use lame and encode mp3's on the fly. It will use the filename extension to detect either .wav or .mp3 and encode accordingly.

#!/bin/bash
# Get pulseaudio monitor sink monitor device then pipe it to 
# sox to record wav, lame to encode to mp3, or flac to encode flac
FILENAME="$1"
STOPTIME="$2"
# Encoding options for lame and flac.
LAMEOPTIONS="--preset cbr 192 -s 44.1" 
FLACOPTIONS="--force-raw-format --endian=little --channels=2 --sample-rate=44100 --sign=signed --bps=16 -f"

if [ -z "$FILENAME" ]; then
    echo -e "
    Usage: $0 /path/to/output.wav or output.mp3 or output.flac
    Usage: $0 /path/to/output.wav or output.mp3 or output.flac stopinseconds" >&2
    exit 1
fi

# Get sink monitor:
MONITOR=$(pactl list | egrep -A2 '^(\*\*\* )?Source #' | \
    grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)
echo "set-source-mute ${MONITOR} false" | pacmd >/dev/null

# Record it raw, and pipe to lame for an mp3
echo "Recording to $FILENAME ..."

if [[ $FILENAME =~ .mp3$ ]]; then
  if [ -z $STOPTIME ]; then
    parec -d $MONITOR | lame $LAMEOPTIONS -r - $FILENAME 
  else
    echo -e "\nStopping in $STOPTIME seconds"
    parec -d $MONITOR | lame $LAMEOPTIONS -r - $FILENAME 2>&1 &
    SPID=$!
    sleep $STOPTIME
    kill -9 $SPID
  fi
fi 

# Note: wav has a limit of about 6.5hrs using 44k 16bit. 
if [[ $FILENAME =~ .wav$ ]]; then
  if [ -z $STOPTIME ]; then
    parec -d "$MONITOR" | sox -t raw -r 44k -sLb 16 -c 2 - "$FILENAME"
  else
    echo -e "\nStopping in $STOPTIME seconds"
    parec -d "$MONITOR" | sox -t raw -r 44k -sLb 16 -c 2 - "$FILENAME" trim 0 $STOPTIME
  fi
fi

if [[ $FILENAME =~ .flac$ ]]; then
  if [ -z $STOPTIME ]; then
    parec -d "$MONITOR" | flac - $FLACOPTIONS -o $FILENAME
  else
    echo -e "\nStopping in $STOPTIME seconds"
    parec -d $MONITOR | flac - $FLACOPTIONS -o $FILENAME 2>&1 &
    SPID=$!
    sleep $STOPTIME
    kill -9 $SPID
  fi
fi 

Del.icio.us! | Digg Me! | Reddit!

Related stories


RSS Feed RSS feed logo
About


3com
3ware
alsa
alsactl
alsamixer
amd
android
apache
areca
arm
ati
auditd
awk
badblocks
bash
bind
bios
bonnie
cable
carp
cat5
cdrom
centos
chart
cifs
cisco
comcast
commands
comodo
compiz-fusion
corsair
cpufreq
cpufrequtils
cpuspeed
cron
crontab
crossover
cu
cups
cvs
database
dbus
dd
dd_rescue
ddclient
debian
decimal
dhclient
dhcp
diagnostic
diskexplorer
disks
dns
dos
dovecot
dsniff
dvdauthor
e-mail
echo
editor
emerald
ethernet
expect
ext3
fat32
fedora
fetchmail
fiber
filesystems
firefox
firewall
flac
flexlm
floppy
flowtools
fonts
format
freebsd
ftp
gdm
gnome
greasemonkey
greylisting
growisofs
grub
hacking
harddrive
hba
hex
hfsc
html
html5
http
idl
ie
intel
ios
iperf
ipmi
iptables
ipv6
irix
javascript
kde
kernel
kmail
kprinter
krecord
kubuntu
lame
ldap
linux
logfile
lp
lpq
lpr
maradns
matlab
memory
mencoder
mhdd
mkinitrd
mkisofs
moinmoin
motherboard
mouse
movemail
mplayer
multitail
mutt
myodbc
mysql
mythtv
nagios
nameserver
netflow
nginx
nic
ntfs
ntp
nvidia
odbc
openbsd
openntpd
openoffice
openssh
openssl
opteron
parted
partimage
patch
perl
pf
pfflowd
pfsync
photorec
php
pop3
pop3s
ports
postfix
power
procmail
proftpd
proxy
pulseaudio
putty
pxe
python
qemu
r-studio
raid
recovery
router
rpc
rsync
samba
schedule
scsi
seagate
seatools
sed
sendmail
sgi
shell
siw
smtp
snort
solaris
soundcard
sox
spam
spamd
sql
sqlite
squid
ssh
ssh.com
ssl
su
subnet
subversion
sudo
sun
supermicro
switches
symbols
syslinux
systemrescuecd
t1
tcpip
tcpwrappers
telnet
terminal
testdisk
tftp
thttpd
thunderbird
timezone
tools
tr
trac
tuning
tunnel
vi
wget
wiki
windows
windowsxp
wireless
wpa_supplicant
x
xauth
xfree86
xfs
xinearama
xmms
youtube
zdump
zic
zlib