[tibco@c0040229 ~]$ cat test.sh.5
#!/usr/bin/expect
echo -n Enter User Id:
read userid
echo -n Enter Password for remote user:
read -s password
hostname=`hostname`
spawn ssh ${userid}@$hostname
expect "Password: "
send "${password}\r"
expect "$ " { send "pbrun su - tibco\r" }
expect "$ " { send "exit\r" }
expect "$ " { send "pbrun bash\r" }
expect "$ " { send "ps -ef |grep apache\r"
expect "$ "
send "exit\r"
[tibco@c0040229 ~]$ cat test.sh.5
#!/usr/bin/ex