linux


Was looking around to find a simple method to find the fullpath or explicit path for the script running.
After a while of searching I found this useful simple snippet: bash, full filename.
And used it like this in the beginning of the script:

PRG="$0"
OLDPWD=`pwd`
B=`basename $PRG`
P=`dirname $PRG`
#  echo BASE:$B  PATH:$P
cd $P
if [ `pwd` != "/" ]
then
FULLNAME=`pwd`/$B
else
FULLNAME=/$B
fi
echo $FULLNAME
cd $OLDPWD
echo `pwd`

… simple but effectiv.

In linux you can use some shell scripting to find a running server process by port number. I came up with this example using awk (watch out for backticks `):

ps aux | grep --regexp="`netstat -nlept | awk '/:8079 / || /:8080 / {split($9,t,"/"); print t[1]}'`"

where you suspect the server ports to be 8079 or 8080. Problem here – if nothing is found then all processes will be listed. For automation you might prefer:

ps u --no-heading -p  `netstat -nlept | awk '/[:]8080 / {split($9,t,"/"); print t[1]}'` 2>/dev/null

… last part will redirect error/help message in case there is no process.

Or put it into a function:

myserver_info() { ps aux | grep --regexp="`netstat -nlept | awk '/8079/ || /8080/ {split($9,t,"/"); print t[1]}'`"; }

this definition you can add to your .bashrc .

Usage:

myserver_info

or pass it within a pipe to “kill <pid>” command for example.

You can extend it further by passing the ports as function arguments … (see Advanced Bash-Scripting Guide: Functions)

Do you know a shorter way to do the same?

Just installed antivirus software for ubuntu: Avast, was very easy, after downloading the .db (rpm is also available):

sudo dpkg -i avast4workstation_1.0.8-2_i386.deb
cd /usr/lib/avast4workstation/share/avast/desktop
sudo ./install-desktop-entries.sh install

… and copy-paste the key which you will get after quick registration process. It works!

On my laptop with an ATI graphic card and kubuntu installed I am using either a dual-head configuration in xinerama mode (screen stretched over two monitors) or a simple one monitor setup.

Recently I messed around with the KDE system settings to get a projector working during a presentation. At home again, I wanted to run X in dual-head mode as usual and replaced the xorg.conf with the backuped xorg.conf.xinerama.
Big was my surprise that despite of this kde started in clone mode. So somehow there must be settings outside the xorg.conf file hiding itself in a cosy corner of my file system. Starting up KDE as an other user would show the correct screen.

Where KDE stores this user-related dispaly setting?

~/.kde/share/config/displayconfigrc

If you have got similiar problems – remove it and everything will be fine again!

Was playing arround with CSS. Especially with dynamic style settings like :hover. I  was naiv enough to use just a simple
<html><head> as a header for my experimental page. It made me wonder why Firefox 2 would not handle div:hover correctly, because Opera and Konquerer did. Finally changed the header to

<!DOCTYPE html PUBLIC “-//W3C//DTD XHMTL 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”>

… and now it works.

Update: It’s know included in the kubuntu distro as package kssh with standard installation procedure.

Switching from Suse to kubuntu went not so smooth as I expected. One small issue was getting to run kssh – a small and useful tool to manage your ssh connections.

This is the way it worked for me:

  1. Download the source file from sourceforge kssh-xx.tar.gz and extract it.
  2. Install the package libqt3-compat-headers.
  3. Run ./configure --with-qt-includes='/usr/include/qt3/' --prefix=/usr/local/
  4. followed by make and make install

That’s it!

If you like to access the kssh-Session directly from Konsole just create new session type in Settings - Configure Konsole - Session with Name:ssh and Execute: kssh .

« Previous Page