core dump checking script.

I was testing a program which crashing every now and then. It is very difficult in such scenarios to keep looking for the core file or keep checking for the running process. So I wrote this simple script that can check for core file in the particular path and keep running until it finds one. You can hack this script to send a mail once the core is found. This is a very simple script. And this should work on solaris too..

#!/bin/bash –

#===============================================================================

#

# FILE: check_core.sh

#

# USAGE: ./check_core.sh

#

# DESCRIPTION: Script to check for core dumps

#

# OPTIONS: —

# REQUIREMENTS: —

# BUGS: —

# NOTES: —

# AUTHOR: Amit Agarwal (AKA), [email protected]

# COMPANY: Individual

# VERSION: 1.0

# CREATED: 12/14/2009 10:19:51 AM IST

# REVISION: —

#===============================================================================

path=/home/amit/

app_name=wine

app_pid=

[ -z $app_name ] || echo $app_name , pid_app=$(ps -u `whoami` -f|grep $app_name |grep -v grep)

[ -z $app_pid ] || echo $app_pid , pid_pid=$(ps -eaf|grep $app_pid |grep -v grep)

if [ -z $pid_app ]

then

while (true)

do

cd $path

if [ -f core ]

then

echo \”Core found\”

exit

else

echo \”continue\”

sleep 5

fi

done

fi

\"Reblog

Running Nested X server

Today I was trying to do a XDMCP connection to the other server ( which is solaris, not sure if that matters) so I used the Xnest server. and used the following command:

Xnest :1 -ac -query <host>

And I was getting the error:

AUDIT: Tue Dec 2 20:40:03 2008: 1470 Xnest: client 2 rejected from IP <>

I tried allowing the host to use the display but not use. The command I used was

xhost + <host name>

But no use…. I tried searchin using google but found nothing. So I \”read the fine manual\” and found the key I was looking for, to disable all the client access control restrictions:

Xnest :1 -ac -query skyware

And voila. Thought will share this for you all 🙂
[edit] will add more details on what is XDMCP tomorrow.

bash script with sql to get the number of records from multiple tables.

Here is the bash script:

#!/bin/sh
names[1]=errorlog
names[2]=amit1log
names[3]=amit2log
names[4]=amit3log
names[5]=amit4log
j=1
echo $1
for i in $( sqlplus amit/[email protected] @get_count.sql |sed  -n \’/COUNT/,/Disconnected/p\’|sed \’/COUNT/ d\’|sed \’/—/ d\’|sed \’/Disconnected/ d\’|tr \’n\’ \’ \’  )
do
temp=${names[$j]}
let count=30-${#temp}
for ((I=1; I <= $count ; I++))
do
printf \” \”
done
echo  \”${names[$j]}    : $i\”
# echo $j
let j=j+1
done
echo
echo

and the required sql script:

select count(*) from errorlog;
select count(*) from amit1log;
select count(*) from amit2log;
select count(*) from amit3log;
select count(*) from amit4log;
quit;

I have verified this to be working on Solaris and Oracle. Might need some changes for mysql, but should not be much.

\"\"