This site is now 100% read-only, and retired.

XML Logo

Posted by uroboros on Sat 29 Jul 2006 at 00:02
Tags: none.

For those that are looking for something looking...

#!/bin/bash

# by Matous Jan Fialka

CPREFIX='<'
CSUFFIX='>'

cecho(){
  local message=$@                                  # the message
  # CLEAR COMMANDS
  message="${message//${CPREFIX}c$CSUFFIX/\e[2J}"   # screen
  message="${message//${CPREFIX}cl$CSUFFIX/\e[K}"   # rest of line
  # ATTRIBUTES
  message="${message//${CPREFIX}n$CSUFFIX/\e[2m}"   # normal
  message="${message//${CPREFIX}v$CSUFFIX/\e[7m}"   # reverse
  message="${message//${CPREFIX}b$CSUFFIX/\e[1m}"   # bold
  message="${message//${CPREFIX}u$CSUFFIX/\e[4m}"   # underline
  message="${message//${CPREFIX}i$CSUFFIX/\e[8m}"   # invisible
  message="${message//${CPREFIX}l$CSUFFIX/\e[5m}"   # blink
  message="${message//${CPREFIX}r$CSUFFIX/\e[0m}"   # reset (white/black)
  # FOREGROUND COLOURS
  message="${message//${CPREFIX}C$CSUFFIX/\e[36m}"  # cyan
  message="${message//${CPREFIX}M$CSUFFIX/\e[35m}"  # magenta
  message="${message//${CPREFIX}Y$CSUFFIX/\e[33m}"  # yellow
  message="${message//${CPREFIX}K$CSUFFIX/\e[30m}"  # black
  message="${message//${CPREFIX}R$CSUFFIX/\e[31m}"  # red
  message="${message//${CPREFIX}G$CSUFFIX/\e[32m}"  # green
  message="${message//${CPREFIX}B$CSUFFIX/\e[34m}"  # blue
  message="${message//${CPREFIX}W$CSUFFIX/\e[37m}"  # white
  # BACKGROUND COLOURS
  message="${message//${CPREFIX}bC$CSUFFIX/\e[46m}" # cyan
  message="${message//${CPREFIX}bM$CSUFFIX/\e[45m}" # magenta
  message="${message//${CPREFIX}bY$CSUFFIX/\e[43m}" # yellow
  message="${message//${CPREFIX}bK$CSUFFIX/\e[40m}" # black
  message="${message//${CPREFIX}bR$CSUFFIX/\e[41m}" # red
  message="${message//${CPREFIX}bG$CSUFFIX/\e[42m}" # green
  message="${message//${CPREFIX}bB$CSUFFIX/\e[44m}" # blue
  message="${message//${CPREFIX}bW$CSUFFIX/\e[47m}" # white

  builtin echo -n -e "$message"
}

ccat(){
  cecho $(</dev/stdin)$'\n' # read stdin
}

# small demo
ccat<<:wq
<C>UN<M>I<l>T<Y>E<u>D<r> <b><R>CO<G>L<l>O<B>R<u>S<r>
:wq

# the end
exit 0

I hope it helps.

--
MJF

 

Posted by uroboros on Sun 16 Jul 2006 at 21:57

Hello.

I have just written small, quick and quite dirty howto on how to set up virtual box using User Mode Linux.

It can be found on http://uml.ligatura.org/.

It is not complete at all; however it works for me very well.

The howto is written in pure XHTML 1.0 Strict (there might still be some "ooops" in the code, but validators does not think so) with external CSS stylesheet, so can be easily converted to plain text.

I hope it helps.

--
mjf

 

Posted by uroboros on Fri 2 Jun 2006 at 18:11
Tags: none.

I know that the code below is NOT real OOP, but it is really nice trick.

#!/bin/bash

# Object-oriented-like programming using pure BASH only:

persons.add ()
{
        local obj_name=$1
        local surname=$2
        local name=$3
        local birth=$4

        eval "$obj_name.set_surname ()
        {
                eval \"$obj_name.surname ()
                {
                        echo \$1
                }\"
        }"

        eval "$obj_name.set_name ()
        {
                eval \"$obj_name.name ()
                {
                        echo \$1
                }\"
        }"

        eval "$obj_name.set_birth ()
        {
                eval \"$obj_name.birth ()
                {
                        echo \$1
                }\"
        }"

        $obj_name.set_surname $surname
        $obj_name.set_name    $name
        $obj_name.set_birth   $birth
}

# Test database:

persons.add 1 'Tachion' 'Charles' '24/02/1979'
persons.add 2 'Quark'   'Carlos'  '05/06/1958'
persons.add 3 'Proton'  'Thomas'  '14/12/1997'

# Print out the test database:

for i in 1 2 3
do
       echo $i:\ `$i.surname`,\ `$i.name`\ \(`$i.birth`\)
done

# The end!

exit 0

The whole concept could be, oh yes, much more improved! I hope it helps!

--
MJF

 

Posted by uroboros on Wed 18 Jan 2006 at 20:06
Tags: none.

Hello everybody,

I switched from ATerm to XTerm (that one in Debian/Sarge GNU/Linux) and registered several problems with keyboard. At first, look at my ~/.Xresources file if there is not some stupid fault. Then I will describe the problem.

XTerm*termName:         xterm
XTerm*eightBitInput:    true
Xterm*eightBitOutput:   true
XTerm*metaSendsEscape:  false
XTerm*modifyCursorKeys: 2
XTerm*alwaysUseMods:    false
XTerm*brokenSelections: true
XTerm*locale:           false
XTerm*curses:           true
XTerm*cursorBlink:      false
XTerm*cursorColor:      red
XTerm*popOnBell:        true
XTerm*visualBell:       true
XTerm*messages:         true
XTerm*underLine:        true
XTerm*printAttributes:  2
XTerm*colorBDmode:      true
XTerm*color256:         true
XTerm*color1:           darkred
XTerm*color3:           orange
XTerm*color4:           navyblue
XTerm*color5:           magenta
XTerm*color6:           deepskyblue
XTerm*color7:           white
XTerm*background:       black
XTerm*foreground:       white
XTerm*pointerShape:     right_ptr
XTerm*font:             -misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-iso8859-2
XTerm*saveLines:        10000

And now the problem:

When I type ctrl-left it will produce 3D output. But in ATerm it produced ctrl-p (I guessed that from behaviour of some programs, typically IRSSI, where ctrl-n|p switches window forth and back). Similarly in XTerm I get 5C instead of ctrl-n as in ATerm. The problem is much more serious, because any other combinations of modifiers and arrow-keys does work as well. My meta-something keypress is destroyed too.

Can anybody help to get back the behaviour I had in ATerm changing configuration of XTerm please? I spent 3 or 4 days (really, not kidding) in "googling out something", tried several tens of different keyboard remapings, XTerm X resources hacks etc., but with no progression. I am very sad of it, because I like XTerm the most (and because it can be found nearly everywhere).

Thank you for your advices.

 

Posted by uroboros on Thu 5 Jan 2006 at 10:11
Tags: none.
Hello,

I need to try some HW routers that are able to connect to OpenVPN. Does anyone have some tips on that topic? Do you have some suggestions which HW router is good to use?

Topology will be:
private <-> HW router <-> OpenVPN Debian/Sarge server <-> HW router <-> private
VPNs will be bridged (I need ARP to go through the tunnels).

Or, if you can, give me some links to resources on the Internet where I can find some information on that topic, please. Google did not give me much information.

 

Posted by uroboros on Mon 31 Oct 2005 at 23:04
Tags: none.
Hello everybody! Because some people from #selinux channel on freenode.net asked me to run wiki pages on SELinux, I did so. The wiki on SELinux can now be found at http://selinux.ligatura.org/ (in case it will grow I will buy new domain name for it too). The main goal is to have complex wiki pages on SELinux where anything important about SELinux, its background, used macro languages etc., including examples, packages for Debian/Sarge GNU/Linux etc., will be found. Start contributing if you can please. We really need new contributors with elan to build such pages.

 

Posted by uroboros on Sun 16 Oct 2005 at 10:45
Tags: none.
Hello. We are looking for contributors to http://selinux.ligatura.org/ wiki. You who can please contribute. The main purpose is to help SELinux novices to setup SELinux enabled server from the scratch.

 

Posted by uroboros on Sat 8 Oct 2005 at 13:49
Tags: none.
Argh... I realised to program quite difficult BASH-only script. I do not want to use any other tools, instead of one or two usages of the `echo' program. Quite funny if you are writing parsing program and commandline options parsing functions in pure BASH, isnt't it? :)

 

Posted by uroboros on Fri 7 Oct 2005 at 09:53
Tags: none.
Hello all great Debian GNU/Linux users!

My name is Matous Jan Fialka (*1979) and I live in Prague, Czech republic, Central Europe. I will try to put some interesting tips & tricks for Debain/Sarge GNU/Linux (and future stable releases too) in here. The main topics will be: security (firewalling included), interesting shell (BASH) tips & tricks, system administration and other things around Debian GNU/Linux.

My English is not perfect at all; so beg my pardon. That's all for now. Have all of you a nice day.