BASH script to enumerate titles and chapters of a dvd and rip the longest one into avi using mencoder. DVD device can be a path to mounted iso (e.g. /mnt/iso/) or a real device (e.g. /media/cdrom0/).
To rip all titles and chapters, try this.
I’ve always used telnet for SMTP testing. Finally, got sick of copy/pasting and decided to write a quick script. But scripting telnet is a pain. Netcat to the rescue!
Call the script with the following arguments:
$ ./smtp.netcat.test mx.example.com 25 from@example.com to@example.com
And here’s the script:
I’ve got a script that loops through a list of directory names and compresses them. There are lots and once in a while I want to check on the progress and find out which directory in the list it’s working on.
The name of the script is compress.sh, tar will run as a child of it, which I can locate using the parent PID:
me@my:~$ show.proc.sh compress.sh USER TT PID PPID %CPU %MEM VSZ STARTED TIME COMMAND me pts/19 1810 24357 0.0 0.0 4496 10:15:37 00:00:00 | \_ /bin/bash ./compress.sh me pts/19 1857 1810 0.5 0.0 3696 10:16:03 00:00:01 | | \_ tar cfj 833444.tar.bz2 833444
show.proc.sh:
1 2 3 4 5 6 7 | #!/bin/bash # get pid pid=$(pgrep $1) ps axfo user,tty,pid,ppid,pcpu,pmem,vsz,start,time,args | head -1 ps axfo user,tty,pid,ppid,pcpu,pmem,vsz,start,time,args | grep $pid | grep -v grep |
compress.sh:
1 2 3 | #!/bin/bash for d in $(cat dir.list.2010-05-11); do tar cfj $d.tar.bz2 $d && rm -rf $d; done |
Was looking for a way to purge Varnish cache when pages are updated or added. WordPress Varnish plugin looks exactly like what I’m after, except it threw up some errors out of the box.
I’m considering implementing Varnish at Stanford Law and have been playing with it here to understand implications and workout issues. One issue is purging pages from cache as they are modified or new pages are added. Varnish provides several methods to do this (varnishadm, telnet and http).
BASH script to enumerate titles and chapters of a dvd and rip each into a separate avi using mencoder. DVD device can be a path to mounted iso (e.g. /mnt/iso/) or a real device (e.g. /media/cdrom0/).
To rip just the longest title, try this.
Let’s say we’ve got a bunch of directories and we’d like to get counts of how many directories are how many levels deep.
Our directory structure:
$ find . -type d . ./test1 ./test1/test1.1 ./test2 ./test2/test2.1 ./test2/test2.1/test2.2 ./test3 ./test3/test3.1 ./test3/test3.1/test3.2 ./test3/test3.1/test3.2/test3.3
There are a number of ways to do this, but I found awk to be most elegant as I wanted to be able to substract an arbitrary number from the result and awk can count and do arithmetic all by itself:
$ find . -type d | while read f; do awk -F'/' '{print NF -1}' | sort | uniq -c | sort -nr; done 3 2 3 1 2 3 1 4
After a clean install of Ubuntu Karmic (9.10), on a box with an Nvidia card (1), went into “System” > “Administration” > “NVIDIA X server settings” and changed configuration to TwinView (I’m using dual monitors), which worked, but saving the configuration returned:
Failed to parse existing X config file '/etc/X11/xorg.conf'
Nothing further found in the logs. The solution was two-fold.
Let’s say you’ve got a string like:
$ string="abc.Cat.def.1.zip.hij.Cut.klm.1.zip.Cat.no.2.zippqrs"
Out of this string, you want to pick out Cat*zip (Cat.def.1.zip and Cat.no.2.zip), “.*” works but is greedy so this grabs too much:
$ echo $string | grep -Eo "Cat.*zip" Cat.def.1.zip.hij.Cut.klm.1.zip.Cat.no.2.zip
This does what we want:
$ echo $string | grep -Eo "Ca[t][^t]*.zip" Cat.def.1.zip Cat.no.2.zip
Previously, I had setup an Ubuntu Karmic box to install Boxee from the apt.boxee.tv APT repository. Since this repository appears to be unmaintained, I’m now reverting back to manual Boxee installs until an updated repository becomes available.