Wednesday, March 30, 2005

Creating a simple user interface in shell scripts

To create a simple menu in a shell script I prefer to use dialog command (see man dialog for more info).

Here I present a simple script with menu that let you select an option and, according to your choice, take an action.

#START
dialog --backtitle "Foo" --title "Bar" --menu "Foo Bar Menu" 15 50 3 Option1 "Option 1" Option2 "Option 2" Option3 "Option 3" 2>/tmp/menuitem.$$

menuitem=`cat /tmp/menuitem.$$`

case $menuitem in
Option1)
echo "Opt 1 chosen";;
Option2)
echo "Opt 2 chosen";;
Option3)
echo "Opt 3 chosen";;
esac

rm /tmp/menuitem.$$
#END

Tuesday, March 29, 2005

Preparation of PDF papers from LaTeX in A4 format

Based on: http://www.cs.sfu.ca/~vis/Tasks/electronic.html
There are two ways to prepare a paper in PDF format from LaTeX:
-use pdflatex command instead of latex
-conversion dvi -> pdf
The former method is easy, however, I prefer the latter because it let me to control the conversion process.
Let's start:
1. Create dvi file (f.e. foo.dvi) from your LaTeX document using latex command with, for example, \documentclass[a4paper,12pt]{report} line in the preamble.
2. Convert dvi to ps format: dvips -t a4 -Ppdf -G0 -o foo.ps bar.dvi
3. Convert ps to pdf document: ps2pdf -sPAPERSIZE=a4 -dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dMonoImageFilter=/FlateEncode bar.ps final_paper.pdf

Tuesday, December 14, 2004

SSH without password - quick howto

1. On your local machine run:
$ssh-keygen -t rsa
and leave empty password. Accept default location of key file.

2. Change permissions to the directory with your unencrypted private key:
$chmod go-rwx ~/.ssh

3. Copy the contents of your ~/.ssh/id_rsa.pub file to ~/.ssh/authorized_keys2 on the remote machine you want to log in without password. If the authorized_keys2 file does not exist - create it.

Sunday, November 28, 2004

Checking new email by korn or biff on secure-connection-require mail servers with stunnel

You can use email application to check if you have new email messages even if the application does not support secure connections and your server requires an encrypting. The solution is stunnel utility. Stunnel opens a port on your local machine and redirects all traffic directed to this port to a different port on another machine using SSL (i.e. secure) connection.
If, for example, your email notification application (Korn in my case) cannot use IMAPS connections but IMAP4 only, you have to set stunnel in such a way that Korn connects unsecurely (using IMAP4) to the port on your local machine and than stunnel redirects packets thru a secure connection to a proper port on your email server.
Let's start. Create or modify '/etc/stunnel/stunnel.conf' file with the content:

pid = /stunnel.pid
setuid = root
[my_imaps_tunneling]
accept = 2143
connect = your.email.server.com:993

Now you only need to configure Korn to connect to localhost at port 2143 (you can choose another unused port number) . Now you have to run '/usr/sbin/stunnel'
If you want stunnel running just after reboot or restart of your machine add:
/usr/sbin/stunnel
line in at the bottom of your '/etc/rc.d/rc.local' file.

Saturday, November 27, 2004

Fedora Core 3 and Palm devices using USB

The common problem with Palm devices using USB connection under Linux are access rights to ttyUSB0 and ttyUSB1 devices. Only root user have permissions to these files. Setting permissions to read/write for group and others is, maybe not very elegant and secure, but fast and easy solution.
Fedora Core 3 uses a new method of device menagement. The device files in the /dev directory exist only if proper devices are connected to the system. Therefore /dev/ttyUSB0 and /dev/ttyUSB1 exist only if HotSync button is pressed in the Palm device and you cannot change permissions to these files permanently.
To solve this problem you have to add two files:
First:
/etc/udev/rules.d/10-visor.rules
and you should add into this file a line: KERNEL="ttyUSB1" SYMLINK="pilot"
and
/etc/udev/permissions.d/10-visor.permissions
and you should add into this file a line: ttyUSB1:$local:uucp:0660
The content of filed in rules.d and permissions.d control the behavior of device manager during the construction of devices in the /dev directory.
Now you can set pilot device to /dev/ttyUSB1 in KPilot or use it in pilot-xfer. But remember, you have to run pilot-xfer -p /dev/ttyUSB1 AFTER fou have pressed HotSync on your Palm.
Based on: http://www.clasohm.com/blog/one-entry?entry_id=12096


Fedora: setting default window manager

To set/change default window manager in Fedora use switchdesk tool. For example. to set KDE your default window manager run: switchdesk kde

Fedora Core 3: problems with X forwarding in SSH

X forwarding by SSH in Fedora Core 3 couses some problem. For example, Emacs or Midnight Commander started on remote machine show errors after several minuts of running. To correct this problem you should create a file ./ssh/config and insert one line into this file:
ForwardX11Trusted yes
That's all, have a nice X forwarding ;)

Friday, November 26, 2004

Fedora Core 3 on Compaq Presario 700

Fedora Core 3 works fine on Compaq Presario 700. The processor cooling is OK, ACPI works out of the box. The only thing that have to be corrected is the problem with PS/2 mouse. TouchPad works fine but PS/2 mouse does not work. To make PS/2 muse working you have to pass an extra parameter to the kernel. The parameter is 'psmouse.proto=imps'. The easiest way to make it works is to add this parameter permanently in /boot/grub/grub.conf
The example line in /boot/grub/grub.conf should look like:
kernel /vmlinuz-2.6.9-1.667 ro root=/dev/VolGroup00/LogVol00 rhgb quiet psmouse.proto=imps

Polish fonts in MPlayer

To get Polish fonts in subtitles in MPlayer one should copy files describing a font from /usr/share/mplayer to ~/.mplayer/font. For example, if one wish to use MS Windows encoded fonts in MPlayer he/she should copy to files from /usr/share/mplayer/font-arial-cp1250/font-arial-24-cp1250 to ~/.mplayer/font/
If ~/.mplayer/font directory does not exist, one should create it.

Saturday, October 30, 2004

Seriously

I decided to use this blog seriously. In fact, I don't have enough time for blogging only for blogging. I want to use this place as a kind of my personal IT knowlegde base. From time to time (but rather often) I solve some problems and the solution, sometimes quite not trivial one, disapears from my mind. Therefore the place for saving such solutions would be very useful for me. Additionally, these tips, howto's and solutions can be useful for other people. So, let's start.