Results 1 to 2 of 2
im trying to put together a IF then.
IF i have 2 connections returned to me in a Dns/host type file and the First one fails on the list im ...
- 07-23-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 2
shell help with IF Then....
im trying to put together a IF then.
IF i have 2 connections returned to me in a Dns/host type file and the First one fails on the list im trying to Initate to the 2nd one or 3 if there is but thats rare. but it only is going to the first one then fails.
Here is the .SH (to initiate a TCL style using expect F)
Code:a=`echo $1 | tr [:upper:] [:lower:]` b=`echo $2 | tr [:upper:] [:lower:]` ipc=`zhosts $a $b mdm | wc -l` if test $ipc -eq 0 then echo "No Modem found." exit 0 fi if test $ipc -gt 3 then echo "$ipc Mdms found in zhosts...you should be more specific." exit 0 fi ip=`zhosts $a $b mdm | head -n 1 | awk '{print $1}'` if test $ipc -gt 1 then echo "More than 1 Modem returned. Using first IP in zhosts: $ip." echo "" fi echo "" echo "******************************************" echo "Connecting to mdm $a$b at $ip" echo "******************************************" out=`/usr/local/bin/modem/chkusrs.exp $ip #| grep 00000 | strings` ((((( trying to see if i put the IF THEN here 1st host fails go to the 2nd Returned))))))) echo"" echo"" echo "Users active on the Modem" echo ":::::::::::::::::::::::::::::::" echo "$out" | awk '{print}' echo ":::::::::::::::::::::::::::::::"
Here is the .exp (expect F)
Code:#!/usr/bin/expect -f # set timeout -1 spawn ssh -o NumberofPasswordPrompts=2 -o ConnectTimeout=3 userAT[lindex $argv 0] expect -exact "ssword:" send -- "1234\r" expect -exact "\>" send -- "sh dis-call-cnt\r" send -- "exit\r" expect eof
this is what i get if it returns a Failed connect (trying to ALSO find a way to remove this because it shows the Pw in cleartext and the chkusrs.exp file )
send: spawn id exp6 not open
while executing
"send -- "1234\r""
(file "/usr/local/bin/modem/chkusrs.exp" line 7)
Users active on the Modem
Thanks
- 07-24-2010 #2Just Joined!
- Join Date
- Jul 2010
- Posts
- 2
if test $ipc = 1 Failed
then
echo "More than 1 Modem returned. Using 2nd IP in zhosts: $ip."
echo ""
fi
out=`/usr/local/bin/modem/chkusrs.exp $ip2
? haha not sure the syntax to put does it read the output buffer on the expect


Reply With Quote