2009/06/16

Ioccc best one liner

This is a brief analysis of korn.c, winner of the 1987 IOCCC. Why? Because. And because many people who shot some explanations have many flaws and conceptual mistakes.

#include <stdio.h>
/*
* Review of one of the best IOCCC one liner winners.
* See International Obfuscated C Code Contest (http://www.ioccc.org)
* ...found other reviews with conceptual mistakes, so I wrote mine...
*
* Winners:  http://www.ioccc.org/years.html#1987
* The code: http://www.ioccc.org/1987/korn.c
* Hints:    http://www.ioccc.org/1987/korn.hint
*
* Rodolfo Alcazar Portillo <rodolfoap@gmail.com>
*/

main() {
/* a simple text */
printf("%s\n","unix");

/* or... */
printf("%six\n","un");

/* adding an unnecesary C text terminator does not change output */
printf("%six\n\0","un");

/* replace \n==\012 which is a printable form of an octal value */
printf("%six\012\0","un");

/* the additional X won't print due to +1 offset */
printf("X%six\012\0"+1,"un");

/* nor any other character */
printf("\021%six\012\0"+1,"un");

/* rephrasing syntax as a text array */
printf(&"\021%six\012\0"[1],"un");

/* And the preprocessor said "Let unix==1". Verification
*      $ cpp -dM /dev/null | grep unix
*   #define __unix__ 1
*   #define __unix 1
*   #define unix 1
*
* Therefore it won't run on Windows unless compiled with cygwin or defined in preprocessor as:
* #define unix 1
*
* ...and therefore redefining the unix variable would raise an error.
*/
printf(&"\021%six\012\0"[unix],"un");

/* &text[n]==&n[text] is basic pointer arithmetics, or addition communitivity */
printf(&unix["\021%six\012\0"],"un");

/* 'a'==0x61 then ('a'-0x61)==0 */
printf(&unix["\021%six\012\0"],"un"+'a'-0x61);

/* Then add any char -X- and a offset of 1 (=='a'-0x60) */
printf(&unix["\021%six\012\0"],"Xun"+'a'-0x60);

/* use a double-quoted string, and its offset, which gives an integer value: 'a'=="a"[0] */
printf(&unix["\021%six\012\0"],"Xun"+"a"[0]-0x60);

/* or the same, with an arbitrary text and offset */
printf(&unix["\021%six\012\0"],"Xun"+"XaXX"[1]-0x60);

/* again, replace 1 with the predefined preprocessor unix==1 value...  */
printf(&unix["\021%six\012\0"],"Xun"+"XaXX"[unix]-0x60);

/* rephrasing, array pointer arithmetics, addition is communitive */
printf(&unix["\021%six\012\0"],"Xun"+(unix)["XaXX"]-0x60);

/* ditto */
printf(&unix["\021%six\012\0"],(unix)["XaXX"]+"Xun"-0x60);

/* at last, change ignored chars to something meaningful */
printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);
}

2008/03/31

Bug photo (2010/03/31)

2007/01/18

Update: Bash-only Linux

This is an update to this old article, which works on Fedora Core 6.

Copy this script into a file, modify the grub entries with your system parameters, run it and enjoy using a dummy linux where you can only write "help", and some useless commands... swear next it'll include the nvidia driver.

#!/bin/bash -v
# Bash only filesystem on a file - rodolfoap@gmail.com

# Create an empty file
dd if=/dev/zero of=/tmp/embed bs=2k count=4k

# Make an ext2fs
/sbin/mkfs.ext2 -v -F -b 2048 /tmp/embed

# Mount it as a loop
mkdir -p /mnt/embed
mount -v /tmp/embed /mnt/embed -o loop -t ext2
cd /mnt/embed

# Create basic structure and fill it with needed files
mkdir bin dev lib
cp -av /dev/tty /dev/console /dev/ram dev/
cp -v /bin/bash bin/
# to found libs needed by bash, use # ldd /bin/bash
cp -v /lib/libtermcap.so.2 lib/
cp -v /lib/libdl.so.2 lib/
cp -v /lib/libc.so.6 lib/
cp -v /lib/ld-linux.so.2 lib/

# Create boot file
cd /tmp
umount -v /mnt/embed
gzip -v < embed > /boot/embed.gz

# Add entry in grub: change root and kernel line with your parameters
cat >> /etc/grub.conf << "EOF"
title Bash Only Filesystem
root (hd0,0)
kernel /vmlinuz-2.6.18-1.2869.fc6 ro root=/dev/ram ramdisk_blocksize=2048 init=/bin/bash
initrd /embed.gz
EOF

# Manually correct grub parameters
read -p "Press ENTER to start editing grub.conf..."
vi /etc/grub.conf

# End script. Reboot with "init 6" and choose the BASH option in GRUB.
# Toto: sos un mostro, thnx.

2006/04/09

The SED beauty

Sed is one of the unix beauties. Simple, standard, absolutely
text/driven, and overall, powerful as The Brain. Look at the examples.

Simple replace:

# sed -e 's/en_US/es_ES/g' /etc/sysconfig/i18n

Replace only on determined lines:

# sed -e '/disable/s/yes/no/' /etc/xinetd.d/pop3s

Adding after a line:

# sed -e '/ListenAddress ::/a\AllowUsers root' /etc/ssh/sshd_config

Deleting a line:

# sed -e '/only_from/d' /etc/xinetd.d/swat

Making a backup, just with "-i"

# sed -i.bak -e '/\/AutoPPP/s/\#//' /etc/mgetty+sendfax/login.config

Replace spaces on start lines:

# sed 's/^ *//' file

More than 2 spaces with one:

# sed 's/[ ]\{2,\}/ /g' file

This is my precious, my ring: Once we have to replace this text...

old: {pdf=FILE text=TEXT}
new: {pdf=FILE title=FILE text=TEXT}

... on *THOUSANDS* of "page.txt" files in a BIIIG directory tree! Of
course, "FILE" and "TEXT" were different on each. With a little help
from my friends Sed and Find, took just a minute:

# find . -name page.txt -print -exec \
> sed -i -e \
> "s/{pdf=\(.*\?\) text=\(.*\?\)}/{pdf=\1 title=\1 text=\2}/g" "{}" \;

Note: ".*" is a GREEDY expression (RT regex FM). To avoid GREEDINESS,
you should use ".*?"

Beautiful.

2006/03/11

Running Tomcat!

How to install TOMCAT on Fedora:

a) Tomcat Itself
yum install tomcat5
yum install tomcat5-webapps
yum install tomcat5-admin-webapps

a2) install java from SUN (could be using Fedora Frog)

b) Change on /etc/tomcat5/tomcat5.conf

JAVA_HOME="/opt/jre1.5.0_06"
(or which suits)

c) In /etc/tomcat5/tomcat-users.xml, put manager/admin roles to tomcat
user:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="manager,admin"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

d) Start service:

# service tomcat5 start

e) Browse http://localhost:8080/

;)

2006/02/22

Disabling Beagle

Very simple. But you must do it every time it updates.

# sed -i -e "/ENABLED/s/yes/no/g" /etc/beagle/crawl-applications
# sed -i -e "/ENABLED/s/yes/no/g" /etc/beagle/crawl-documentation

May The Source Be With You...

2006/01/18

Linux/PHP with Windows/MSSQLServer Howto

Made on Fedora Core 6. Suppose other distros work the same. Good luck!

- Install freetds, the unixODBC-kde gui and php-odbc, for making php work with odbc

[rodolfoap] /root # yum install freetds unixODBC-kde php-odbc

- Connectivity test, port 1433TCP. If you get "1>", ok. Elsewhere, its a firewall, ports, routing, etc. issue.

[rodolfoap] /root # tsql -S 192.168.1.20 -U sa -P sjasdad
locale is "en_US.UTF-8"
locale charset is "UTF-8"
1>

- Create an entry in /etc/freetds.conf:
[192.168.1.20]
host = 192.168.1.20
port = 1433
tds version = 8.0

- Add the entry in /etc/odbcinst.ini
[MSSQLServer]
Description = MSSQLServer
Driver = MSSQLServer
Servername = 192.168.1.20
Database = Bienes
UID = sa
PWD = sjasdad
Port = 1433

- And /etc/odbcinst.ini
[MSSQLServer]
Description =
Driver = /usr/lib/libtdsodbc.so.0
Driver64 =
Setup = /usr/lib/libtdsS.so.1
Setup64 =
UsageCount = 1
CPTimeout =
CPReuse =

- Now, you should get "SQL>"
[rodolfoap] /root # isql -v MSSQLServer sa sjasdad
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
(There you can perform SQL queries)

- The odbc php test page (for my database, of course):
[rodolfoap] /root # cat /var/www/html/odbc.php

<?
$connect = odbc_connect("MSSQLServer", "sa", "sjasdad");
odbc_exec($connect, "use Bienes");
$result = odbc_exec($connect, "SELECT * FROM Personas");
while(odbc_fetch_row($result)){
print(odbc_result($result, "CodPersona").' '.odbc_result($result, "Apellidos") . "<br>\n");
}
odbc_free_result($result);
odbc_close($connect);
?>

- If you want to use mssql functions, install php-mssql from http://remi.collet.free.fr/ , adding the repository and issueing "yum install php-mssq". And then,

[rodolfoap] /root # cat /var/www/html/mssql.php
<?
$connect = mssql_connect("192.168.1.20", "sa", "sjasdad");
mssql_select_db("Bienes", $connect);
$result = mssql_query("SELECT * FROM Personas");
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
while($row = mssql_fetch_array($result))
echo $row["IdPersona"] . " - " . $row["Apellidos"];
mssql_free_result($result);
mssql_close($connect);
?>

Yastá!

2005/12/28

Beautiful dirty trick: Embedded only-file bash filesystem

This is a beautiful trick. Tip includes: making an empty 10Mb file; creating a filesystem on it; creating basic tree; creating devices; copying bash and required libs; unmounting it; making it a boot file and adding a grub entry.

Put this on an executable-file-script and run it (tested on Fedora Core 4):

#!/bin/bash
#Script start ----------------------
#Bash only filesystem on a file - rodolfoap@hotmail.com

#Create an empty 10Mb file
dd if=/dev/zero of=/tmp/embed bs=1k count=10k

#Make an ext2fs
/sbin/mkfs.ext2 -q /tmp/embed

#Mount it as a loop
mkdir /mnt/embed
mount /tmp/embed /mnt/embed -o loop
cd /mnt/embed

#Create basic structure and fill it with needed files
mkdir bin dev lib
cp -a /dev/tty /dev/console /dev/ram dev/
cp /bin/bash bin/
#to found libs needed by bash, use # ldd /bin/bash
cp /lib/libtermcap.so.2 lib/
cp /lib/libdl.so.2 lib/
cp /lib/libc.so.6 lib/
cp /lib/ld-linux.so.2 lib/

#Create boot file
cd /tmp
umount /mnt/embed
gzip < embed > /boot/embed.gz
echo "
title Bash only filesystem
root (hd0,2)
kernel /boot/vmlinuz-2.6.14-1.1644_FC4 ro root=/dev/ram init=/bin/bash
initrd /boot/embed.gz" >> /etc/grub.conf
#Script end ------------------------

Reboot and choose the "Bash only filesystem" option.

2005/10/13

OS Tasting

A pic worths a thousand words. There are a lot of (linu)x-based distros, most of them oriented to specific user or application. This interesting page collects a lot of representative shots.

http://shots.osdir.com/

2005/10/10

Desktop GNUs

GNUs -mainly Linux- state of the arts for servers could be entitled as great. But that highlight not shows the same face for desktop usage. There are many issues to be confronted before we can see a really mature approach in migrating to linux environment. They can be organized in four main items, as we see on many posts of experienced admins, by the way, the most crystal approach: migration, stability, simplicity, comfort. Migration deals with the technical field: moving the user and his environment to this new gadget (thanks, wine; not wine for drinking, but the open application that is not an emulator; must include int this topic the learning curve fact). Stability, mainly with applications; if has been seen that the base OS handles tasks as a rock, is not the same with all applications. Comfort, with the maturity and easiness focus of task handling. The four issues lack off in some way. Not as a constant, but as everything, each case is to be handled with most care.

Years ago, we think man will live on the moon, by Y2k. Now we live another type of revolution: internet. We forgot the moon. Same way, on the desktop, we may probably not replace just the OS on final users' computers. Maybe the approach is based on powerful mainframes, generating desktops on dumb terminals. Simple, manageable, echologic. See the DiscoverStation solution as an example.

Anyway, there are new resources on the net, u r not alone. Check them out and you will find the named state of the arts has evolved. Here are a couple of them. You can google for more and be surprised.

www.desktoplinux.com/
www.desktoplinuxconsortium.org/
www.debian.org/devel/debian-desktop/
www.userful.com/products/library/

Estracted from http://www.swlink.net/~styma/LinuxForTheMasses.shtml:

* Linux/Fedora can supply the functionality that the end user needs once it is set up. It can do this more reliably than Windows.

* The application interface for the Linux end user tools (office, k3b, games, etc.) is similar enough to the windows interface to make the transition relatively painless.

* In it's current state, Fedora needs a technically savvy person to get it set up to a state that the end user can do things. Many of the issues revolve around licensing issues, such as the installs of xmms-mp3 and k3b-mp3. Some of the Firefox plugin issues fall into this category.

* A tool, similar in concept to the wine-tools, would be useful in the distribution. It would have options like "use MP3 format files", and if selected would add the livna repo's and check if k3b, xmms, and others with -mp3 versions were installed. If so, it would yum down the mp3 versions of these RPM's. The same would be true for enabling Java in the browser. Nothing I did could not be done by an automated tool.

* Non-technical users need a support structure to use their Linux machines effectively. I suspect this is mostly true if one is migrating the users away from Windows. If they know how to do something in windows, it is easier to switch back than to go through the learning curve on Linux. The question remains, what do the non-technical Windows users do when they get stuck? I suspect they either thrash around till they get something to work or just give up. I do not have good data on this and don't see how to get it. As Dr. Heisenberg discovered, measuring things affects the object being measured.

* It is possible that some of the procedures used could have been done better. "How do I" requests I got were often things I don't do often so I researched the issue to supply an answer.




2005/10/01

VNC tools mainframe-like terminals

What about buying a 50 bugs Pentium-I used computers(32 Mb RAM, 1Gb HD), and using the last Fedora Core 4 release, or Sarge? You can do that with linux VNCServer. VNC, on linux has the ability of creating desktop environments for each client. Here is an example with FC4.

1. Install vncserver on linux server. Install vncviewer from RealVNC on clients. You need 128Mb RAM on server for each client.
2. Create client entries like the line examples on /etc/sysconfig/vncserver

VNCSERVERS="1:rodolfoap"
VNCSERVERARGS[1]="-geometry 800x600"

3. su as each user. Run vncserver. It will create the ~/.vnc structure.
4. Edit ~/.vnc/xstartup:

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
exec gnome-session &

5. Check your firewall rules! Start service. Connect from clients to SERVER_IP:5901 (each client is enumerated from 5901).

This method allows you to have a lot of clients working on his own homes. Startup scripts, allowable programs, quotas. But thats a KDE or GNOME issue.

2005/09/09

Documentation-time logic

Document! But do not take this task as an addition to developing. Here is an example of an integrated way of developing and socumenting at the same time.

The example shows a script which includes its own documentation. With simple tools, we generate man documentation from its output.

First of all, you need this formatted output: --version and --help. This example applies the "fortunes" script written in a previous post.

[rodolfoap] /home/rodolfoap > fortunes --version
GNU fortunes v0.1

Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Written by Rodolfo Alcazar <rodolfoap@hotmail.com>
[rodolfoap] /home/rodolfoap > fortunes --help
GNU fortunes is a personal fortunes engine organizer, written in bash.

Usage: fortunes [OPTION]

Options:
-e edit fortunes file
-l enters learning mode
-m enters multiline-learning mode
--help shows this help
--version shows version

Examples:

fortunes --help shows this help
fortunes -e edits fortunes file
fortunes generates a random fortune
fortunes -l starts learning mode

Report bugs to rodolfoap@hotmail.com

Start documentation process:

[rodolfoap] /home/rodolfoap > help2man fortunes|gzip -f>fortunes.1.gz

User just access the man page. In this case, the man page is not stored in its proper location.

[rodolfoap] /home/rodolfoap > man ./fortunes.1.gz

2005/08/07

Linux power tools and classic formats

This is an interesting one. I had a 200-pages book, and need a 50-page book, with 4 little pages on each page. So I based this script on psdim, one of a thousand linux power tools:
#bin/bash
IMAGES=4
echo Must have installed psdim!
echo Converting...
gs -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=$1.tmp.ps $1
echo PSDIM output --------------------
psdim -$IMAGES $1.tmp.ps
echo PSDIM output end ----------------
pstops $(psdim -$IMAGES $1.tmp.ps) $1.tmp.ps $1.tm2.ps
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$1.tiled.pdf $1.tm2.ps
rm $1.tmp.ps $1.tm2.ps
rename .pdf.tiled.pdf .tiled.pdf $1.tiled.pdf
echo Done!

You just need to start exploring GNU power tools now!

2005/07/13

Scripted Server Setup

As a tasks-overloaded systems administrator, I really experienced the information is, by far, the most important asset of a company motto. Enough to risk your job or your career if you lose some. So, years ago, I focused on two highlights on servers management: keeping safe data and automatizing administrative processes. I will focus on this article on the automatizing administrative processes issue.

With Turbolinux, I wrote once a script, which allows me, runt before a fresh install, to complete a mailserver setup. Install tooks 10 minutes. Script execution (install additional rpms, copying mailboxes from other server, replacing configuration files, configure services and reboot), 5 minutes. With bash.

The only problem was that next year we, the company, found ourselves working with SuSE. A couple of years, with Fedora. We expect the script will just need a little review with each scenario changing. False. The script needed a rewrite every time. So, as a part of writing automatization processes scripts, we include the "source code" of our needs.

This is an excerpt of a class I dictated. Useful for a mailserver setting up.

Linux Fedora Core 4 Server
==========================

- Install Fedora Core 4

- Do Not install SELINUX.

- Custom Type installation - no packages

- Hostname=www.example.org.bo

Firewalling config with IP Tables
=================================

Add this rules to /etc/sysconfig/iptables:
-A RH-Firewall-1-INPUT -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 110 -j ACCEPT

# service iptables restart

Create yum repository
=====================

Install createrepo with rpm:
# yum -y install createrepo

Create basedir:
# mkdir -p /rpm/Fedora/RPMS
# cd /rpm/Fedora/RPMS

Put each disc on cdrom and
# mount /media/cdrom; cp -v /media/cdrom/Fedora/RPMS/*.rpm . ; eject

On /etc/yum.repos.d/fedora.repo comment baseurl=, mirrorlist, gpg...,
and add
baseurl=file:///rpm/

Create repository:
# createrepo /rpm

Config Apache web server
========================

# yum -y install httpd
# service httpd start
# chkconfig httpd on

Config Pop3 server with Dovecot
===============================

# yum -y install dovecot
# service dovecot start
# chkconfig dovecot on

Config SMTP server with Sendmail
================================

# yum install sendmail-cf
# cd /etc/mail/

# vi sendmail.mc

Uncomment (wipe dnl):
dnl define(`confAUTH_OPTIONS', `A p')dnl
dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5
LOGIN PLAIN')dnl

Comment (put dnl):
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

Generate sendmail cf file:
# m4 sendmail.mc > sendmail.cf

Add domains served by server:
# echo example.org.bo >> local-host-names

Add the networks this server accepts mail from:
# echo 10.0.0 RELAY >> access

Regenerate hash tables by restarting service
# make
or
# service sendmail restart

Install a webmail server with SquirrelMail
=============================================

# yum install squirrelmail

Fill organizational data with
# /usr/share/squirrelmail/config/conf.pl
Must complete numbers 1 (general data), 7 (Motd) and 10 (languaje, here
we use es_ES)

Install Mailman mailing lists server
====================================

Install mailman:
# yum install mailman

Config mailman:
# cd /usr/lib/mailman/bin
# ./mmsitepass

Maybe this is not necessary, but we must know where it is:
# vi /etc/mailman/mm_cfg.py # put fqdn='www.example.org.bo'

Create lists
# ./newlist # create "mailman" list and copy generated aliases
to /etc/aliases
# ./newlist # create "mylist" list and copy generated aliases
to /etc/aliases
# ./mailmanctl start
# service sendmail restart
# service httpd restart
# service mailman start
# chkconfig mailman on

(on redhat, mailman require MAILMAN_USER and GROUP = 'root' on
Defaults.py)

You can see how easy is to "compile" this to bash, with kickfiles, sed, yum or apt.

Additional tip: whilst including this lines as comments on the script, include instructions if you are gonna execute interactive commands...

2005/04/15

Increasing productivity

Wanna load a bunch of users/passwords to your system? Wanna auto-generate mailman lists? Wanna concentrate all your weekly backups on a single server directory? Wanna batch? Got it! But only on text-based systems (read x-based OSs). If you manage IT facilities, YOU WILL NEED:

* cron, at, batch

* man man

* perl, bash

And some specific tools examples:

* chpasswd, sed, awk, rsync, scp

* mailman: all in /bin dir. sync_members will save you days if you schedule it with your /etc/passwd or adduser changes!

* sendmail: m4, makemap

* apache: mod_auth_pam, if you wanna simplify managing and have a LDAPping-Krb alternative

* Windows admins: Have you tried bash tools on your cmd.exe line?

X-based servers are in a highly mature state. They had evolved to satisfy most common administrative requests. Just search.

A quote from "A quarter Century of Unix" by P Salus" states, quoted from Simone Demblon :)

* write programs that do one thing and do it well.
* write programs that work together
* write programs that handle text streams, because that is a universal interface

Cheers!

2005/03/03

Detailed Linux Boot Process

Linux boot process is based, among others, on the System-V filed structure. Can read more on this article.

http://www.ccoss.org/tutorials/lfs/Linux_from_Scratch_A_Tour.htm

Fedora boot process, in more detail:

http://openskills.info/infobox.php?ID=228

2005/02/16

High leveling common tools

Tools like bash worths a "man bash" reading. You can even make recursive scripts! Lets play...
#!/bin/bash

function generalista ()
{
if [ $1 == "0" ] || [ $1 == "1" ]
then
echo 1
else
VARF=$(($1-1))
echo $VARF
generalista $VARF
fi
}

if [ "$#" == "1" ]
then
if [ $1 -ge 0 ]
then
time LISTA=$(generalista $1)
echo El factorial es el producto de los factores de esta lista : $LISTA
FACTORIAL=1;
for FACTOR in $LISTA
do
TEMP=$(($FACTORIAL*$FACTOR))
FACTORIAL=$TEMP
done
echo Entonces, el factorial de $1 es $FACTORIAL, aunque eso no es correcto...
else
echo Error: integer MUST be positive
fi
else
echo Usage: $0 positive_integer
fi

2005/01/07

Bash humor quotes database aids

#!/bin/bash

FORTFILE=/home/rodolfoap/bin/fortunes.mine
EDITOR=vi

HLPTXT=$(cat <<EOT
GNU fortunes is a personal fortunes engine organizer, written in bash.

Usage: fortunes [OPTION]

Options:
-e edit fortunes file
-l enters learning mode
-m enters multiline-learning mode
--help shows this help
--version shows version

Examples:

fortunes --help shows this help
fortunes -e edits fortunes file
fortunes generates a random fortune
fortunes -l starts learning mode

Report bugs to rodolfoap@hotmail.com
EOT)

VERTXT=$(cat <<EOT
GNU fortunes v0.1

Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Written by Rodolfo Alcazar
EOT)

case "$1" in
"")
fortune $FORTFILE
;;
"-e")
$EDITOR $FORTFILE
/usr/sbin/strfile $FORTFILE
echo
;;
"-l")
echo "Entering learning mode."
echo
read -p "> " QUE
echo -e "$QUE\n%" >> $FORTFILE
echo
/usr/sbin/strfile $FORTFILE
;;
"-m")
echo "Entering multiline learning mode. End questions and answers with ^D."
echo
echo -n "> "
QUE=$(cat)
echo -e "$QUE\n%" >> $FORTFILE
echo
/usr/sbin/strfile $FORTFILE
;;
"-h"|"--help")
echo "$HLPTXT"
;;
"-v"|"--version")
echo "$VERTXT"
;;
esac



Fun, hah? With this basics I've wrote a flashcards studying tool. Drop me a line if you want it. Even better, you can write your own!

2004/01/03

Curriculum Vitae (EN)

Ing. Rodolfo José Alcázar Portillo
rodolfo.alcazar.portillo@gmail.com; NIE Y0555335Z, born La Paz, Bolivia, 30/04/1969

(Entities located in La Paz, Bolivia, unless specifically mentioned)

Studies
  • Cisco CCNA certification, Technologies Transfer Center, 2002
  • Networks/Comunications Specialization postgrade, Aquino University , 2002
  • Internet/ Intranet Postgrade, Franz Tamayo Private University, 2001
  • Systems Engineering, Catholic University, Cordoba, Argentina, 1993
  • Bachelor in humanities, American Institute, 1988
Specialization Areas
  • Implementation, management and administration of network and systems facilities (at present preparing material for possible publication of a book: Administracion de Centros de Computo - IT Facilities Management)
  • Free software for enterprise applications and systems management
  • Networks, data communications and Internet/Intranet technology; communications equipment of voice and data networks (Cisco, Motorola, mainly; routers, switches, firewalls)
  • Information and data management; systems auditing; informatic systems and communications standards
  • Operating systems: Linux, SCOUnix, Ultrix, AIX, Windows
Experience related to the position

2003 - 2010 Systems administrator, GTZ
  • Specialized technical consultancy to governmental clients (local and foreign) in design and implementation of IT services;
  • IT facilities and data/voice networks design and implementation; supervision of LAN and WAN network cabling and interconnection with 6 offices in several city locations;
  • Implementation of Intranet/Internet and administrative services for internal clients;
  • IT services and systems management.
2000 - 2003 Networks and Information Manager; Information Quality Control Technician, Ministry of Education (Ministerio de Educacion)
  • IT facilities and services design, implementation and management; supervision of network cabling of 2 Ministry of Education buildings and governmental buildings throughout the country;
  • IT services and systems management;
  • Educational information quality strategy development/implementation;
  • organization of operatives in collecting redundant information in more than 2000 schools in all the country; pollsters and supervisors team coordination (70 simultaneously).
1997 - 1999 Systems Coordinator, World Vision Bolivia
  • Coordination of the IT team;
  • Partners consultancy in Colombia, El Salvador, Honduras and Costa Rica ;
  • IT facilities and services implementation and management, based on a design proposed from Costa Rica; supervision of network cabling;
  • Participation in international systems auditories;
  • Strategic and operative planification trainer; participation in revision of 40 operative plans and 6 strategic development plans of projects and national office.
1997 Computer center responsible, Nexxo superagency of Bolivian Stock Market Agency (Bolsa Boliviana de Valores)
  • Participation in implementation of stock values negotiation systems with a Colombian specialists team; participation in implementation of WAN network with 15 agencies of local stock market in several points of La Paz;
  • Network protocols analysis for price fixing, as specialists assistance to ENTEL.
1996 Data Analyst, National Secretary of Education (Secretaria Nacional de
Educacion)
  • Development and implementation of bolivian educative entities database;
  • Network cabling and IT services specifications design for buildings of the Educational Reform Program;
  • Participation in publication of 10 volumes of educative information compendiums.
1994 - 1996 Computer Center Administrator, Banks and Financial Organizations
Superintendency (Superintendencia de Bancos y Entidades Finacieras)
  • National Entities and Persons Financial Database management;
  • Participation in migration of the Computer Center and network cabling and IT services design, SBEF building;
  • Participation in design and implementation of IT services according to specifications of World Bank counterpart.

2004/01/01

Curriculum Vitae (ES)

Ing. Rodolfo José Alcázar Portillo
rodolfo.alcazar.portillo@gmail.com; NIE Y0555335Z, La Paz, Bolivia, 30/04/1969,


Estudios realizados
  • Certificación Cisco – CCNA, Centro de Transferencia de Tecnologías, 2002
  • Posgrado Especialización Redes/Comunicaciones, Universidad de Aquino, 2002
  • Posgrado Internet/ Intranet, Universidad Privada Franz Tamayo, 2001
  • Ingeniería de Sistemas, Universidad Católica Córdoba, Argentina, 1993
  • Bachillerato en humanidades, Instituto Americano, 1988
Áreas de especialización
  • Implementación, gestión y administración de centros de cómputo (actualmente preparando material para posible publicación del libro: Administración de Centros de Cómputo)
  • Software libre para aplicaciones empresariales y de gestión de sistemas y redes
  • Redes, comunicaciones de datos y tecnología Internet/Intranet; equipos de comunicación de redes de voz y datos (Cisco, Motorola, principalmente; routers, switches, firewalls)
  • Administración de datos e información; auditoría de sistemas; normas de sistemas y comunicaciones
  • Sistemas operativos Linux, SCOUnix, Ultrix, AIX, Windows servers
Experiencia relacionada al cargo

2003 – 2010  Administrador de sistemas, GTZ
  • Asesoría técnica especializada a clientes gubernamentales (locales y en el exterior) en diseño e implementación de servicios informáticos
  • Diseño e implementación centro de cómputos y red de datos y voz; supervisión cableados e interconexión LAN y WAN con 6 oficinas en distintos puntos de la ciudad;
  • Implementación servicios Intranet/Internet y administrativos para clientes internos
  • Administración de sistemas y servicios informáticos
2000 – 2003 Administrador de redes y datos; Técnico en Control de Calidad de Información, Ministerio de Educación
  • Diseño, implementación y gestión centro de cómputos y servicios informáticos; supervisión cableado 2 edificios Ministerio de Educación y edificios gubernamentales en el interior
  • Administración de sistemas y servicios públicos
  • Desarrollo/implementación estrategia calidad información educativa; Organización operativos de recolección de información redundante en más de 2000 escuelas de todo el país; coordinación equipo de encuestadores y supervisores (70 simultáneamente)
1997 – 1999 Coordinador de Sistemas, World Vision Bolivia
  • Coordinación equipo de Sistemas
  • Apoyo a partners en Colombia, El Salvador, Honduras y Costa Rica
  • Implementación y gestión centro de cómputos y servicios informáticos sobre un diseño propuesto desde Costa Rica; supervisión cableado de redes;
  • Participación en auditorías internacionales de sistemas;
  • Capacitador en planificación estratégica y operativa; participación en revisión de alrededor de 40 planes operativos y 6 planes estratégicos de desarrollo de proyectos y oficina nacional
1997 Encargado del Centro de Cómputos, Nexxo superagencia de Bolsa
  • Participación en implementación de sistemas de negociación de valores con equipo de especialistas colombianos; participación en implementación de red WAN con 15 agencias de bolsa en varios puntos de La Paz
  • Análisis de protocolos de redes para tarifación, asistencia a técnicos de ENTEL
1996 Analista de datos, Secretaría Nacional de Educación
  • Desarrollo e implementación de base de datos de entidades educativas de Bolivia
  • Diseño especificaciones cableados y servicios de red para edificios del Programa de Reforma Educativa
  • Participación publicación de 10 tomos de compendios de información educativa
1994 – 1996 Administrador del centro de cómputos, Superintendencia de Bancos y Entidades Financieras
  • Administración de datos financieros y Central de Riesgos nacional
  • Participación migración centro de cómputos y diseño cableado y servicios informáticos Ed. SBEF – Plaza Isabel La Católica
  • Participación diseño e implementación servicios informáticos según especificaciones contraparte Banco Mundial