Archive for the 'Linux' Category

mount WebDav in Ubuntu/Linux from FireFox

Gallery_mount_with_webDavOn a standard photo Gallery, you can select to mount Gallery on your desktop with a WebDAV client. I searched for an easy solution to mount webdav from the browser but was not able to find any scripts doing so with only one click. See the first picture to see how you find the link on a Gallery 2.0.

Here is the simple script: (Read more for an advanced script)

#!/bin/sh
 
DAVURL=`cat "$1" | grep ":url" | egrep -o "http[^< \"]+"`
DIR=`echo $DAVURL | egrep -o "[a-zA-Z0-9\.]" |xargs | sed s/\ //gi`
MOUNTPATH="/media/webdav.$DIR"
 
gksu -- mkdir $MOUNTPATH
gksu -- mount.davfs -onoaskauth $DAVURL $MOUNTPOINT
nautilus $MOUNTPOINT

Continue reading ‘mount WebDav in Ubuntu/Linux from FireFox’

Epoch to human

How often haven’t I needed to convert a Epoch timestamp (unixtime) to Human readable format?

 

 
 

From commandline:

date -d @1000000000

(replace 1000000000 with your epoch, needs newer version of date)

For more reading, see http://www.epochconverter.com/

undefined symbol: Perl_Tstack_sp_ptr

I got this error after a upgrade of perl on my ubuntu desktop station:

rolf@untuome:~/.xmltv$ tv_grab_no_gfeed --output /home/rolf/.xmltv/tv_grab_no_gfeed.xml
/usr/bin/perl: symbol lookup error: /home/rolf/.perl/lib/perl5/i486-linux-gnu-thread-multi/auto/List/Util/Util.so: undefined symbol: Perl_Tstack_sp_ptr
rolf@untuome:~/.xmltv$ mv /home/rolf/.perl/lib/perl5/i486-linux-gnu-thread-multi /tmp
rolf@untuome:~/.xmltv$ tv_grab_no_gfeed --output /home/rolf/.xmltv/tv_grab_no_gfeed.xml
downloading listings

Synergy over sshtunnel

A ssh tunnel will slow down the mouse pointer which can result in a slow response on the client machine. But it will encrypt and secure the input information like your passwords typed on the keyboard. Synergy sends these unencrypted over the network.

Here is how to do it:

On the machine you are using(typing on), run synergy bound to the lo (localhost) interface. Synergys will act as a keyboard and mouse server for the machines you want to control. Do it like this:

synergys -a localhost

Remember that you need to have a /etc/synergy.conf for synergys: On the machine you using(typing on). There you need to specify that SynclientName has access to connect to you.

Then, start the ssh port-tunnel by forwarding port 24800 on localhost yourmachine connecting to it’s own localhost on port 24800:

ssh -R localhost:24800:localhost:24800 yourmachine

Start the synergy client on the machine you want to remotely control and connecting it to localhost (which is ssh-tunneled to yourmachine)

DISPLAY=:0 sudo synergyc -n SynclientName localhost

This was only a small howto on connecting two linux machines with synergy.

How to download over 6000 Free True Type fonts?

A small script to download over 6000 free TrueType Fonts from a webpage.
This script should be for learning purpose only. Removing XX makes you guilty!
Continue reading ‘How to download over 6000 Free True Type fonts?’

Send each directory over ssh to their own gzipped tar file (.tar.gz)

Find directories in the directory you are standing in:
-maxdepth 1 -type d

Exclude the first ‘.’ :
-mindepth 1

Remove the ./ part from the list:
sed s@^.\/@@gi

Tar-gzip the directory with compression 1 for faster network transfer:
tar -cv $a | gzip -1

Send the file to the dd program:
ssh -l user server "dd of=/path/to/$a.tar.gz"

Wrapping it into a small example script:

for a in `find . -mindepth 1 -maxdepth 1 -type d | sed s@^.\/@@gi`; do 
(tar cv $a | gzip -1) | ssh -l user server "dd of=/path/to/$a.tar.gz" ;
done

I suggest you install a ssh-key before doing this, or you will have to type the user password for each directory. This script does not support spaces in directory names.

The script below handle directories with space in them, just like “Document and Settings”.
I print each file (%p) with a colon at the end. The seperator used by the for-loop is also the colon which is defined by the IFS variable.

IFS=":"
for a in `find . -mindepth 1 -maxdepth 1 -type d -printf '%p:' | sed s@^\".\/@\"@gi`; do
(tar cv $a | gzip -1) | ssh -l username servername "dd of='/outputdir/$a.tar.gz'" ;
done
unset IFS

Boot the ubuntu-live cd, making the network start.
livecd$ ssh-agent
livecd$ ssh -l username server -A
server$ ssh-add

root@ubuntu:/media# dd if=/dev/sda2 | ssh -l username hostname "dd of=/path/to/save/my_backup_sda2.ntfs.disk"
The authenticity of host 'hostname (192.168.1.1)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hostname,192.168.1.1' (RSA) to the list of known hosts.
username@hostname's password:
38957625+0 records in
38957625+0 records out
19946304000 bytes (20 GB) copied, 2541 s, 7,8 MB/s
37811184+2292882 records in
38957625+0 records out
19946304000 bytes (20 GB) copied, 2532.89 s, 7.9 MB/s
root@ubuntu:/media#

Rebuild f-spot on Ubuntu Hardy

Got source files from
https://launchpad.net/ubuntu/+source/f-spot

Add the lines above to ubuntu sources..

echo "deb http://ppa.launchpad.net/ruben/ubuntu hardy main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/ruben/ubuntu hardy main" | sudo tee -a /etc/apt/sources.list

Install missing libs:

apt-get install cli-common-dev mono-gmcs libmono-dev libmono-system-runtime2.0-cil 
apt-get install libgnome-keyring1.0-cil libusb-dev libgphoto2-2-dev 
apt-get install libglitz1-dev libglitz-glx1-dev gtk-sharp2-gapi mono-mcs
apt-get install gtk-sharp2-gapi
apt-get install libglib2.0-cil

Clean up the mess and rebuild it..

rm -rf f-spot-0.5.0.3
dpkg-source -x f-spot_0.5.0.3-0ubuntu4.dsc
cd f-spot-0.5.0.3
dpkg-buildpackage -rfakeroot -b

Linux: Copy file and directory permissions

How do you copy permissions recursively from one directory to another if you forgot to do ‘cp -rp’ when copying.

 

 

Continue reading ‘Linux: Copy file and directory permissions’

Copy/link files with spaces in the filename

$ cat filelist.txt
/full/path/to/img_1529 (Modified).jpg
/full/path/to/img_1593 (Modified).jpg
/full/path/to/img_1582 (Modified (3)).jpg
/full/path/to/img_1546 (Modified).jpg
/full/path/to/img_1612 (Modified).jpg
/full/path/to/img_1663.jpg
/full/path/to/img_1670 (Modified (2)).jpg
/full/path/to/img_1713.jpg
/full/path/to/img_1552.jpg
/full/path/to/img_1538 (Modified).jpg
 
$ cat filelist.txt | xargs -d\\n -n1 -I'{}' cp -p "{}" /tmp/

Find (new) images that does not exist in the f-spot database.

Here is a small script which will give some ideas of how it can be done:

 
# Backup your f-spot db-file to /tmp/
cp ~/.gnome2/f-spot/photos.db /tmp/
 
# Run a sql to find the photos matching my photo uri+2008, and 'DSC*.jpg'.
# split the list that sqlite3 generates. I just want the photo name, so that's my 10'th field.
# Uppercase every filename and sort it, then put it into a file.
sqlite3 ~/.gnome2/f-spot/photos.db 'select uri from photos where uri like "file:///home/%/Photos/2008/%DSC%.jpg"' | cut -d/ -f10 | tr 'a-z' 'A-Z' | sort > /tmp/gotFromFspot.list
 
# Go to the directory where you have your camera files. (ps: You should not have photos from 2008 in this directory.
cd /media/PHONE CARD/DCIM/100MSDCF/
 
# find all files and put them into another list.. 'CardFileList.list'
ls -1 | sort > /tmp/CardFileList.list
# Diff the file lists. We only care about the ones that does not exist in gotFromFspot.
diff /tmp/gotFromFspot.list /tmp/CardFileList.list | grep ">" | sed s/> //gi >/tmp/ResultList.list
 
mkdir /tmp/NewImagesTmpDestination
# Loop every file and copy the new, not existing in the f-spot photo db to /tmp/d/
for tmpvariable in `cat /tmp/ResultList.list'; do  cp $tmpvariable /tmp/NewImagesTmpDestination ; done