Archive for February, 2007
Linux: Generating a html file list
Posted by JohannesTheDeveloper in fun with Linux on February 26th, 2007
Another small snippet (note: missing header & footer)
find files/ -printf '<tr><td><a href="%h/%f">%f</a></td></tr>\n'> list.html
Latex: Makefile
Posted by JohannesTheDeveloper in fun with Linux on February 26th, 2007
Makefile for generating pdfs out of tex files.
I use the folder structure: tex/ for the tex files, img/ for images and want the pdf in the base folder.
Makefile:
%.pdf: tex/%.tex
rm -f $*.pdf
cd tex; pdflatex $*.tex
cp tex/$*.pdf $*.pdf
Calling it:
while sleep 1; do make -f /mnt/daten/Daten/Allgemein/Nützlich/Latex/Makefile *.pdf; done
Parameter is the pdf you want (with the same filename tex/NAME.tex).
Linux: Encrypted Zip file
Posted by JohannesTheDeveloper in fun with Linux on February 26th, 2007
A small snippet:
zip -e9 Bewerbungen.zip *.pdf
Bash: Shell over highly-guarded HTTP
Posted by JohannesTheDeveloper in fun with Linux on February 8th, 2007
You got 2 Linux/Unix PCs across the country, and between them are two big firewalls and proxies.
So each one can basically only send HTTP-Requests to the Internet, not directly to each other.
Having a little php script on a webserver, I wrote 2 shell scripts so one can interact across this connection.
The script for the machine you want to control:
#!/bin/bash
# The client's script
SERVER="http://<fill in server adress>/exchange.php"
GETURL=$SERVER"?mode=get&what=commands"
TARGETURL=$SERVER"?mode=gather&what=output"
TMP=/tmp/O-zero.1
while sleep 3
do
wget --quiet --output-document - ${GETURL} |
sed 's/\r$//'
done |
bash 2>&1 3>&1 4>&1 5>&1 |
while sleep 1
do
# We don't want every line in a seperate request
# So we group them:
{
echo -n "a="
while read -t 2 line
do
echo "$line"
done
} > $TMP
# Send output if we have some
if [[ $(wc -c <$TMP) != "2" ]]; then
wget --quiet --post-file $TMP --output-document - $TARGETURL
fi
done
The script for the operator:
#!/bin/bash
# The operator's script
SERVER="http://<fill in server adress>/exchange.php"
GETURL=$SERVER"?mode=get&what=output"
TARGETURL=$SERVER"?mode=gather&what=commands"
TMP=/tmp/O-zero.2
while sleep 3
do
wget --quiet --output-document - ${GETURL} |
sed 's/\r$//'
done &
while read line;
do
echo "a=$line" > $TMP
wget --quiet --post-file $TMP --output-document - $TARGETURL
done
wait
The script on the Webserver (commands.txt and output.txt must be writeable).
<?php
header('Content-Type: text/plain');
if($_GET['what'] === 'commands')
$file = 'commands.txt';
if($_GET['what'] === 'output')
$file = 'output.txt';
if($_GET['mode'] === 'gather' && !empty($file)){
$fd = fopen($file,"a");
@fwrite($fd,$_POST['a']);
}
if($_GET['mode'] === 'get' && !empty($file)){
echo join(file($file));
$fd = fopen($file,"w");
}
?>
Ajax: A chat application
Posted by JohannesTheDeveloper in Happy Hacking on February 4th, 2007
First, try it: http://johbuc6.coconia.net/tests/ajaxchat/ajaxchat.html
I got the code from http://www.linuxuser.at/chat/index.html and adapted it.
Special features:
- see who is online
- change alerts (for leaving the window open)
Get it and change it! ajaxchat.tar.gz (gz, 4 KB)
Linux: Fedora alternative startup
Posted by JohannesTheDeveloper in fun with Linux on February 4th, 2007
Ever wanted you laptop to just do one thing?
You want to turn it on and it should just play music?
But it takes ages
- to boot,
- then you have to login
- wait again
- then start the music app
- press play
I did modify my Fedora to allow an alternative bootup that does just that, but automatically:
in grub.conf:
title Fedora Core root (hd0,1) kernel /boot/vmlinuz-2.6.18-1.2257.fc5 ro root=LABEL=/ quiet initrd /boot/initrd-2.6.18-1.2257.fc5.img savedefault title Please, play some music for me. root (hd0,1) kernel /boot/vmlinuz-2.6.18-1.2257.fc5 ro root=LABEL=/ quiet nonetwork music initrd /boot/initrd-2.6.18-1.2257.fc5.img
In /etc/init.d/network, quite at the beginning:
if grep -i nonetwork /proc/cmdline >/dev/null; then exit 0 fi
In /etc/X11/prefdm, quite at the beginning:
[ -f /etc/X11/switchlogin.sh ] && /etc/X11/switchlogin.sh
That file looks like this:
#!/bin/sh XDM=/etc/X11/xdm if grep -i music /proc/cmdline >/dev/null; then sed 's/AutoLoginUser=user/AutoLoginUser=music/g' < $XDM/kdmrc.orig > $XDM/kdmrc else cat $XDM/kdmrc.orig > $XDM/kdmrc fi
It switches between the user user and the user music, kdmrc.orig contains my normal bootup setup.
What is still missing is to add the following shell script to the user music’s startup (I gave him gnome):
#!/bin/sh setxkbmap de_neo rhythmbox & sleep 4; rhythmbox --play & sleep 4; rhythmbox --play & sleep 4; rhythmbox --play &
Sometimes the prog takes a time to startup.
Bottom line: Start the laptop, select the music startup, close the laptop, connect the earphones, put it in the backpack, and after some time, it starts to play.
NEO … my hero
Posted by JohannesTheDeveloper in fun with Linux on February 4th, 2007
I finally managed to install the NEO keyboard layout on my fedora core 5 system…
It ran already for a while in Windows, now i took the time to adapt the map file.
It’s nice to be able to lay your keys wherever you want them, especially I hate dead keys.
Changes:
- The standard tilde is dead, I changed it
- The pipe is at some strange place, I like it at Alt-> (standard)
Maybe I’ll upload a picture of my laptop with the layout one day.
If you need it, its attached here: de_neo (5 KB)
Links:
- Creator’s page
- Will it be included in your next distro? (I never thought other people would use it)
- A picture of the layout
OS: OpenBSD 4.0 install report
Posted by JohannesTheDeveloper in fun with Linux on February 26th, 2007
Isn’t that beautiful?
My GRUB bootloader says:
I got 4 operating systems on my laptop now (the second is a modified startup of the first, I describe it here).
With my newest, OpenBSD 4.0, you may now call me a wizard of OS. Here is some info about it:
Install:
Making the boot iso yourself is really very easy, I went with amd64, and added some manuals and the release songs to it.
The install wasn’t that hard, I just had to read a bit about disklabels. Beside, I already had a FreeBSD some time ago.
Also the following question is a little misleading ;-)
… (If you accept zero, it will overwrite your partition table … )
By the way I found a nice partition finder utility: Testdisk. It’s FOSS, runs under Linux and windows without setup. I usually went with PCIRecovery.
Anyway, I wasn’t too freaked out about it, I generally backup my data.
Troubles
Ok, here the experiences with it:
Solution:
For permanent, add that /etc/mixerctl.conf
Solution: there is none.
Temporary solution:
works well, but this is a workaround.
Mounting ext2fs:
With the entries in fstab:
That works. Got the devicenames from disklabel.
package manager:
packages
Packages I added and worked quite well: bash, gnome-session, gdm, xmms, mozilla-firefox, gedit, nano, gajim, …
other tweaks
So I’m now in GNOME it looks quite good.
And it’s damn fast.
PS: This was on a HP Pavillion dv8000
comment
No Comments