Ok, so I'm trying to make a little script that tells me what my pre-pay balance is for my 2degrees 3G.
I can get it to do everything I want at the moment... IF its working. But I want to be able to build in intelligence so that it tells me if the balance check failed for whatever reason.
So.. this is a typical output of what would happen when its working..
--------------------------------------------------------------------
AT
OK
at+cusd=1,"*100#1#",15
+CUSD: 0,"Your bal is $112.24. Remaining bals: Texts 470 See 'Your 2degrees' for all bals &exp dates",15
OK
--------------------------------------------------------------------
But what I want it to do is one of 2 things..
Scenario 1 - When it works like in the example above, I want it to use 'expect' to determine that it has succeeded in doing the check.
Scenario 2 - When it doesn't work and the out its expecting doesn't come in, it times out after 30 seconds and determines that the check failed.
This is what my script looks like at the moment, but it doesn't work..
--------------------------------------------------------------------
send at+cusd=1,\"*100#1#\",15\r
set timeout 30
expect {
"+CUSD: 0,\"Your bal is$",15"
timeout 10 gosub TimeoutSub
}
print "\r\n\011\011PASS"
log USSD,BAL,PASS
! killall minicom
exit 0
TimeoutSub:
print "FAIL"
log USSD,BAL,FAIL
! killall minicom
exit 1
--------------------------------------------------------------------
The problem is that no matter what the result its still doing the same thing...which is:
print "FAIL"
log USSD,BAL,FAIL
! killall minicom
exit 1