Tuesday, November 23, 2010

Auto Login using expect script


#!/bin/expect -f
# Parse argument Variables
set user [lrange $argv 0 0]
set ipaddress [lrange $argv 1 1]

spawn ssh -l user ipaddress
match_max 100000
# Look for passwod prompt
set timeout 2
expect "*(yes/no)?" {
send "yes\r"
}
expect "*?assword:*"
send "password\r"
interact
expect eof


---End---

./test user 192.1.1.1

Enablling traces in Bash script


#!/bin/bash

# require that all variables be set, otherwise the bash script will abort
set -o nounset

# pltTrace=2 # uncomment pltTrace to enable trace

export nodeType=""
export BaseProgName=`basename $0`
export ProgName=${BaseProgName}.$$

# if pltTrace is not already defined, define it
# this will allow individual programs to be
# debugged without turning on debugging for
# all scritps that source this file
if ! [ ${pltTrace:+1} ]
then
declare -x pltTrace=0
#change pltTrace to 1 to turn on debug for
# all scripts that haven't defined pltTrace
fi

if [ $pltTrace -ge 2 ]
then
PS4='${ProgName}:$LINENO: pltTrace-> '
set -o xtrace
fi

echo `date '+%Y%m%d.%H%M.%S'` ${BaseProgName} ": ENTER: Echoing here ..."

echo hello
if [ ! : ]; then
echo hello 2
fi
echo hello 3

---END---
Execute:
export pltTrace=2
./test

ttest.16898:37: pltTrace-> date +%Y%m%d.%H%M.%S
test.16898:37: pltTrace-> echo 20101124.0558.51 test ': ENTER: creating ZFS pools and files systems ... starting'
20101124.0558.51 test : ENTER: creating ZFS pools and files systems ... starting
test.16898:40: pltTrace-> echo hello
hello
test.16898:42: pltTrace-> '[' '!' : ']'
test.16898:47: pltTrace-> echo hello 3
hello 3

Monday, May 31, 2010

How to Use Purify

To use purify, you must create an instrumented executable file. For example, if your program consists of two files named main.C and List.C, you could created an instrumented executable named a.out by typing:

purify g++ -g main.C List.C

(As usual, use the -o flag to produce an executable named something other than a.out.)

Once you have produced an instrumented executable, just run it in the usual way (by typing its name, and, if your program is designed to use them, the appropriate command-line arguments).

Don't be surprised if the instrumented executable runs much more slowly than the non-instrumented version; it may also be much larger than the non-instrumented version.

And Run the executable automatically purify window will get opened along with the your executable.

Visit Following link for example
http://pages.cs.wisc.edu/~cs368-1/handouts/purify.html#example