Hi,
right now we faced a problem that we didn't know what port a db2 was listening to and to solve the issue we issued the following commands in a Solaris box (should also work in AIX or RedHat):
//check what port DB2 should be using:
$ db2 get dbm cfg | grep SVCENAME
//if it's not numeric, check the number in /etc/services:
$ grep db2c_db2svc01 /etc/services
//and if you want to confirm that DB2 is indeed listening to that port, issue:
$ netstat -a | grep DB2
//Or in Windows client, check if you can get a tcp connection
c:\>telnet server_ip server_port
cheers,
Borys Marcelo
quarta-feira, 4 de fevereiro de 2009
How to retrieve lines before and after in a AIX / Solaris box when -B and -A options are not available
Hi,
when you find yourself trying to retrieve the lines before and after of an occurrence of an exception or keyword in a log file and you discover that in AIX or Solaris box you don't have such a options in grep command, the below command will help you in that issue:
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=10 a=10 s="NullPointerException" server.log
where:
b means Before and is the same as the -B option in gnu grep
a means After and is the same as the -A option in gnu grep
s means the keyword or string you are looking for
cheers,
Borys Marcelo
when you find yourself trying to retrieve the lines before and after of an occurrence of an exception or keyword in a log file and you discover that in AIX or Solaris box you don't have such a options in grep command, the below command will help you in that issue:
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=10 a=10 s="NullPointerException" server.log
where:
b means Before and is the same as the -B option in gnu grep
a means After and is the same as the -A option in gnu grep
s means the keyword or string you are looking for
cheers,
Borys Marcelo
sexta-feira, 11 de janeiro de 2008
Getting rid of ^M character while printing out a report
Hi, recently I got in turns with a problem in a CSV report. The report was printed out correctly but because of a ^M a new line had been added and the report was generated with extra lines. A mishmash. But fortunately, I've found a solution:
In the variable that holds your value to be printed out in a report, say CSV, you need to use awk to remove the ^M (carrot M)
DETAILS=`echo $DETAILS | awk -v RS="^M" -v ORS="" '{print}'`
but BE SURE you make
In the variable that holds your value to be printed out in a report, say CSV, you need to use awk to remove the ^M (carrot M)
DETAILS=`echo $DETAILS | awk -v RS="^M" -v ORS="" '{print}'`
but BE SURE you make
^M USING "CTRL-V CTRL-M" NOT BY TYPING "CARROT M"! because if you don't, ^M will not be replaced at all as you are typing it as literal not as a metacharacter.
* CRTL+V=^
CRTL+M=M
^M= carriage return
the above worked for me, please post here if you have any questions. Thanks.
sexta-feira, 4 de janeiro de 2008
Linux is not Windows
Here is a good article for new Linux users that explain very well that Linux is not a Windows and what the new user have to expect of it:
http://linux.oneandoneis2.org/LNW.htm
http://linux.oneandoneis2.org/LNW.htm
How to recover your xorg configuration in Ubuntu / Linux?
Hi,
first of all, it's a good practice to keep a backup of the xorg configuration file right after Ubuntu installation finishes. Because you will already have a running xorg configuration that you will be able to use in case of something getting wrong, say, after a 3D video card installation or something liked. Then, let's walk through the steps:
1 - If you cannot see anything when GDM starts, you need to start linux in a safe-mode or just issue CRTL+ALT+F1 to see a terminal prompt
2 - Log into you Linux as usual and go to /etc/X11/
3 - issue ls -l xorg* and you will see xorg configuration files:
$ ls -l xorg*
-rw-r--r-- 1 root root 2390 Nov 23 00:28 xorg.bak_rodando
-rw-r--r-- 1 root root 2516 Nov 19 21:11 xorg.bichado
-rw-r--r-- 1 root root 2390 Jan 4 09:25 xorg.conf
-rw-r--r-- 1 root root 2300 Nov 18 01:16 xorg.conf~
-rw-r--r-- 1 root root 2305 Nov 18 01:33 xorg.conf.backup
-rw-rw-r-- 1 root root 2719 Nov 22 23:55 xorg.conf.backup-ati-fglrx
-rw-r--r-- 1 root root 803 Nov 17 03:58 xorg.conf.original-0
-rw-r--r-- 1 root root 823 Nov 18 01:41 xorg.conf.original-1
4 - If this is the first time you are restarting your computer, than you can use the xorg.original-0
5 - then as root or with sudo command issue
sudo cp xorg.conf.original-0 xorg.conf
say y[es] if prompt for a confirmation.
6 - Now if you tried everything and yet you are not able to see anything when GDM starts, you will need to generate a brand new xorg conf file. To do so, issue as root or with sudo:
sudo
first of all, it's a good practice to keep a backup of the xorg configuration file right after Ubuntu installation finishes. Because you will already have a running xorg configuration that you will be able to use in case of something getting wrong, say, after a 3D video card installation or something liked. Then, let's walk through the steps:
1 - If you cannot see anything when GDM starts, you need to start linux in a safe-mode or just issue CRTL+ALT+F1 to see a terminal prompt
2 - Log into you Linux as usual and go to /etc/X11/
3 - issue ls -l xorg* and you will see xorg configuration files:
$ ls -l xorg*
-rw-r--r-- 1 root root 2390 Nov 23 00:28 xorg.bak_rodando
-rw-r--r-- 1 root root 2516 Nov 19 21:11 xorg.bichado
-rw-r--r-- 1 root root 2390 Jan 4 09:25 xorg.conf
-rw-r--r-- 1 root root 2300 Nov 18 01:16 xorg.conf~
-rw-r--r-- 1 root root 2305 Nov 18 01:33 xorg.conf.backup
-rw-rw-r-- 1 root root 2719 Nov 22 23:55 xorg.conf.backup-ati-fglrx
-rw-r--r-- 1 root root 803 Nov 17 03:58 xorg.conf.original-0
-rw-r--r-- 1 root root 823 Nov 18 01:41 xorg.conf.original-1
4 - If this is the first time you are restarting your computer, than you can use the xorg.original-0
5 - then as root or with sudo command issue
sudo cp xorg.conf.original-0 xorg.conf
say y[es] if prompt for a confirmation.
6 - Now if you tried everything and yet you are not able to see anything when GDM starts, you will need to generate a brand new xorg conf file. To do so, issue as root or with sudo:
sudo
dpkg-reconfigure xserver-xorg
follow on screen instructions and you will have your xorg conf to previous state.
please post a comment whether any question.
Borys
quinta-feira, 27 de dezembro de 2007
How to use IF statement more properly
Hi,
when I first developed a sh script I ended up with a bunch of If's clauses since the only IF statement I had heard about it was the
if [ ]
then
fi
this because if you are using IF statement with square brackets, you can only test for a unique assertion. But, what if you need to do a short circuit using || and &&? If you are not able to do that you will probably end with a bunch of ifs to accommodate this deficiency. But there is a solution, you need to use the IF statement with a double parenthesis, like this:
* no extra space between (( and $a and between 10 and )) allowed
if (($a < 0 && $b < 10))
then
#statements go here
fi
when I first developed a sh script I ended up with a bunch of If's clauses since the only IF statement I had heard about it was the
if [ ]
then
fi
this because if you are using IF statement with square brackets, you can only test for a unique assertion. But, what if you need to do a short circuit using || and &&? If you are not able to do that you will probably end with a bunch of ifs to accommodate this deficiency. But there is a solution, you need to use the IF statement with a double parenthesis, like this:
* no extra space between (( and $a and between 10 and )) allowed
if (($a < 0 && $b < 10))
then
#statements go here
fi
quarta-feira, 26 de dezembro de 2007
How to return the number correspondent to any given Month name
Hi,
today I'm facing a problem: How to return the number corresponding to Jan, Feb, Mar.... in the date String returned by
chage -l ?
For example, when I issue chage -l myusername it gives me:
Last password change : Nov 17, 2007
Password expires : Feb 15, 2008
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
So, I made a grep command in union with a gawk command to bring me the 3 last pieces of this lines for any line containing expires in their name. So it gives me
Feb 15, 2008
never
never
so, with Feb 15, 2008 in my hands, what I could do with that? Nothing, because I cannot use Feb to compare with another date in order to get number of days for the next user account expiration. Given this scenario, we have to options:
1 - Create a function with a whole bunch of ifs in order to switch between Name / Number like:
if [ $1 == "Jan" ]
then
return 1
and so...
2 - use the built in Linux date command:
/bin/date --d="Feb 15, 2008" +%m
the above gives you the number 11 as result. Then you can issue /bin/date +%m and get current month and do the needful to calculate days before account expiration or password expiration.
Please, post here if you have any questions, thanks.
today I'm facing a problem: How to return the number corresponding to Jan, Feb, Mar.... in the date String returned by
chage -l
For example, when I issue chage -l myusername it gives me:
Last password change : Nov 17, 2007
Password expires : Feb 15, 2008
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
So, I made a grep command in union with a gawk command to bring me the 3 last pieces of this lines for any line containing expires in their name. So it gives me
Feb 15, 2008
never
never
so, with Feb 15, 2008 in my hands, what I could do with that? Nothing, because I cannot use Feb to compare with another date in order to get number of days for the next user account expiration. Given this scenario, we have to options:
1 - Create a function with a whole bunch of ifs in order to switch between Name / Number like:
if [ $1 == "Jan" ]
then
return 1
and so...
2 - use the built in Linux date command:
/bin/date --d="Feb 15, 2008" +%m
the above gives you the number 11 as result. Then you can issue /bin/date +%m and get current month and do the needful to calculate days before account expiration or password expiration.
Please, post here if you have any questions, thanks.
Assinar:
Postagens (Atom)
