ILOAPP image server download loop
June 14, 2009
The script below downloads a number of images from a photo archive on an iloapp server to the current directory. It is very basic with no usefull user controls, but it is simple enough for most people to understand it I hope.
# Expands image urls and downloads them with wget
imgname=""
urlname=""
for (( i = 0; i <= 44; i++ ))
do
urlname="http://iloapp.gydesen.biz/gallery/madeira2009?Download&album=10&image=""$i"
imgname="Karen-billede-""$i"".jpg"
wget --output-document=$imgname $urlname
done
Twittable scripts
April 13, 2008
There are a lot of folkes having fun with the shell, here are some that can be twitted and some tips.
Master script for dir2slideshow
April 2, 2008
I finally managed to make a script to autogenerate dir2slideshow files for all the picture directories I have. It is not entirely general but the only thing that needs to be changed is the input to the loop, which should be a list of directories. Besides the previous post included a bug which has been fixed, so please use this version -the name changed to path2name since now also dirs are allowed.
#!/bin/bash
# control script for dir2slideshow
# List of directories containing pictures. I guess that this could go into a variable right away...
function mydirs {
ls -d /home/asger/Pictures/*/ | egrep '200[[:digit:]]-([[:alnum:] _-])*';
}
# Extract file or dir names from full paths, note without any slashes.
function path2name {
echo $1 | egrep -o '/([[:alnum:] _-])*/?$' | sed 's/\///g';
}
# Interface to dir2slideshow, make it easy to change settings globally.
function d2s {
dir2slideshow -n $(path2name $1) $1;
}
# Loop through the list to generate all files.
for i in $(mydirs) ; do
d2s $i
done
path2file – get filenames from full paths
April 1, 2008
Still working on the dvd-slideshow thing I have found that it would b nice to globally control the generation of control files for it, and in that process I have found that it is an advantage to extract file names from full paths. This can be achieved with the following simple function:
function path2file {
echo $1 | egrep -o '/([[:alnum:] _-])*$' | sed 's/\///' ;
}
which takes a path as argument and gives back the file eg:
path2file ~/Documents/Programming/dvd-slideshow/dvd-burn
returns:
dvd-burn
This of course does not work for windows paths, but you can always exchange slash for backslash (only the escaped ones) to make it windows oriented
Edit: well of course there is already a tool for this in bash namely the history command with all its nice options. See for instance this tutorial.
Problems with dvd-slideshow
March 29, 2008
dvd-slideshow is an interesting app that can make dvd’s with slideshows of your pictures with cool effects and audio. However there are some bugs in the newest .deb package so I have had to manually install the fix available on the svn repository at SourceForge. Link to main page, check it out: dvd-slideshow. Well the repository only contains the source and a short guide to the installation that was not readily understandable to me, so it did not work out. I tried doing this:
svnrep=/home/asger/Documents/Programming/dvd-slideshow;
sudo mkdir -p /opt/dvd-slideshow/{bin,share/{doc,man/man.1}};
sudo mkdir /opt/bin; cd /opt/bin; sudo ln -s /opt/dvd-slideshow/bin;
cd /usr/local/bin; sudo ln -s /opt/dvd-slideshow/bin;
sudo cd $svnrep;
sudo cp dvd-* dir2slideshow gallery1-to-slideshow \
jigl2slideshow /opt/dvd-slideshow/bin;
sudo cp man/* /opt/dvd-slideshow/share/man/man.1;
sudo cp doc/* /opt/dvd-slideshow/share/doc/;
sudo cp dvd-slideshowrc ~/.dvd-slideshowrc;
I probably missed something with the links, because the system did not recognize the commands in the program… Therefore I took the cheezy solution and just reinstalled the broken .deb package and manually replaced the binaries with the new ones from the svn repository.
sudo cp dvd-menu dvd-slideshow dir2slideshow gallery1-to-slideshow \ jigl2slideshow /usr/bin
And now it at least is active again but I will still have to see if the old problems are solved, so stay tuned.
rsync
March 25, 2008
rsync is a cool tool for synchronizing data across servers. It can be used in many ways, but I presently use it to transfer files between the server at the physics department and my own computer.
rsync -avR sourcefolder destinationfolder
There are some problems though with permissions though so be sure to allow reading and writing data across the interface…
Firewall issues
March 8, 2008
I am using the Cisco vpn client 4.8 and the firestarter 1.0.3 firewall, and unfortunately they do not work together out of the box. Disabling the firewall will let the vpn trafic through but this is not the optimal solution. To solve this problem I have found these references:
- LAMNK – recipy for allowing vpn trafic – the vpn device (aka cipsec0) can be fond in the status tab in the firestarter GUI when loaded.
- Cisco – firewall trouble shooting.
- Firestarter – vpn guidelines.
Now /etc/firestarter/user-pre have been updated according to LAMNK’s directions with the ifa vpn server address and my cipsec0 device. Apparently the vpn device that is shown in the firestarter device list is wrong since it says cipsec instead of the real name cipseq0, and now things seem to work out fine.
Edditing of the user-pre file in firestarter, please note that this is empty per default.
- chmod 600 /etc/firestarter/user-pre.
- sudo gedit /etc/firestarter/user-pre.
- Follow instructions on LAMNK.com.
- sudo /etc/init.d/firestarter restart.
- Cross your fingers and try out the setup with your browser.
ifalogon
March 7, 2008
Script to log onto the ifavpn server, should be completed by adding the rest of the necessities for working from the samba drive.
.bash_profile
March 7, 2008
Reading the excelent turoial on bash scripting at linuxcommand.org I realized that I needed a .bash_profile setup file in order to easily access homewritten bash scripts. This file was avaliable at answers.lunchpad.net and I just copy pasted it into emacs and saved in ~ and changed permissions with chmod u+x .bash_profile. Now I am able to save my scripts in the ~/bin directory and then just call them without any reference to the explicit path which is kind of nice.
Hello
March 7, 2008
This blog is for my own amusements but if case of interest please do not hesitate read onwards. In fact what I fill this space exclusively notes regarding scripting on my Ubuntu box.
Enjoy!