Don’t call it test

There are quite a few names to avoid in your scripts. Even if there are not reserved-words, keep away ! I’ll start with test cd $HOME/bin vi test   echo hello world chmod +x test ./test   hello world The problem is that it may break your other scripts $ ssh localhost test 1 = 2 && […]

run sudo, ssh, password, su in simulated interactive mode

Some commands do not like non-interactive mode $ passwd <<EOF > oldpassword > newpassword > newpassword > EOF Changing password for user lsc. Current password for lsc@example.com: passwd: Authentication token manipulation error $ echo oraclepassword | su – oracle standard in must be a tty $ echo sudopassword | sudo su – oracle [sudo] password […]

fun with cron

Today I find out that my scheduler was too busy to execute all jobs in my crontab !? * * * * * (while :;do ssh example.com :; done) 59 23 19 06 * touch /tmp/bang my while loop is going to produce so much hangs on the cron deamon that it may not be […]

How to quit crontab -e without overwritting cron

Imagine my crontab * * * * * /usr/bin/date > /tmp/foo I am writing the date to /tmp/foo every minute $  cat /tmp/foo Thu Jul  5 08:45:01 CEST 2012 Now I want to view my crontab in my EDITOR (vi). $ crontab -e I do not quit yet. In the meantime, my colleague modify the crontab. * […]

[alert] AIX Posix Timezone issue

Maybe you did get or you will get an issue with the date command in AIX. expected behavior, Linux $ TZ=NZST-12NZDT,M10.1.0/2,M3.3.0/3 date Sat Mar 17 00:14:54 NZDT 2012 $ TZ=Pacific/Auckland date Sat Mar 17 00:14:58 NZDT 2012 unexpected behavior, AIX $ TZ=Pacific/Auckland date Sat Mar 17 00:15:50 GMT+13:00 2012 $ TZ=NZST-12NZDT,M10.1.0/2,M3.3.0/3 date Fri Mar 16 […]

delete unused shared memory segments from an Oracle instance

Once upon a time, a dba issues some kill -9 to clean up dying database processes. Or the database instance crashes. This will left some shared memory segments. Note 68281.1 describe how to remove them on a server with multiple databases. First, list the ipc process $ ipcs IPC status from /dev/mem as of Mon […]

pstree in AIX

For those who do not want to download some linuxlike freeware on your aix box, use ps -T 🙂 ps -fT 2412672      UID     PID    PPID   C    STIME    TTY  TIME CMD   oracle 2412672       1   0   Sep 05      –  0:00 /u01/app/oracle/product/OAS   oracle  630956 2412672   0   Sep 05      –  6:11     \–/u01/app/oracle/prod   oracle 1347672  630956   0   Sep 05      – 15:32        |\–/u01/app/oracle/   oracle 1437836  630956   0   Sep 05      –  1:02        |\–/u01/app/oracle/   oracle  880820 1437836   0   Sep […]

Generate network graph from command line

I recently wrote on gnuplot, today I tried another command line utility to generate graphs, graphviz, version 2.24.0 on AIX5L. Pretty straightforward syntax : (   echo "digraph Emp {"     sqlplus -s -L scott/tiger << EOF       set pages 0 lin 120 hea off feed off       select         ename ||'->'||         (select ename from emp where empno=e.mgr) || ';' […]

What is the current setting of NLS_LANG in sqlplus?

I just learnt a neat trick from Oracle Support. How do you see the current value of NLS_LANG in SQLPLUS ? HOST is not the right answer. E.g.: Unix: SQL> host echo $NLS_LANG AMERICAN_SWITZERLAND Windows: SQL> HOST ECHO %NLS_LANG% %NLS_LANG% The correct setting is revealed by @.[%NLS_LANG%] E.g.: Unix: SQL> @.[$NLS_LANG] SP2-0310: unable to open […]

Time offset in Unix

What is the time offset of the current date in Unix? perl -e '   $t=time;   @l=localtime($t);   @g=gmtime($t);   $d=$l[2]-$g[2]+($l[1]-$g[1])/60;   $gd=$g[3]+$g[4]*31+$g[5]*365;   $ld=$l[3]+$l[4]*31+$l[5]*365;   if($gd<$ld){$d+=24};   if($gd>$ld){$d-=24} print ($d."\n")' 2 Am I in summer (DST)? perl -e 'if((localtime)[8]){print"yes"}else{print "no"}' yes

to cvs or to subversion

First surprise, after migration, the size of my subversion folder is double the size of my cvs folder. With a bunch of 2Gb disks shared amoung dozens of unix persons, and regular reminders the current usage reached 100%, you will feel the pain of having each developers doublesizing its home directory… The reason is a […]

extract xml from the command line

I just discovered this morning this cool utility in my /bin directory : xmllint You can use it to extract values from your xml files within your shell scripts $ cat foo.xml <emplist>   <emp no="1">     <ename>John</ename>   </emp>   <emp no="2">     <ename>Jack</ename>   </emp> </emplist> $ echo 'cat //emplist/emp[@no="1"]/ename/text()'|   xmllint –shell foo.xml |   sed -n 3p John I […]

cd

Do you know cd ? I thought I did until this afternoon … OK, let’s start some basic. I create two directories $ echo $SHELL /bin/ksh $ mkdir /tmp/foo $ mkdir /tmp/bar create a symlink /tmp/bar/baz pointing to /tmp/foo $ ln -s /tmp/foo /tmp/bar/baz create a file foo1 in foo $ touch /tmp/foo/foo1 change to […]

cd OLD NEW

Something I like in ksh is to change from /my/old/directory/path to /my/new/directory/path by typing cd old new. This does not work in bash So I had to find a workaround 😉 $ ksh $ cd /app/oracle/product/11.1.0.6/database/rdbms/admin $ cd 6 7 $ pwd /app/oracle/product/11.1.0.7/database/rdbms/admin $ bash $ cd 7 6 bash: cd: 7: No such file […]