Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


193 posts

Master Geek


Topic # 67180 29-Aug-2010 20:07
Send private message

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

Create new topic


193 posts

Master Geek


  Reply # 374627 31-Aug-2010 01:41
Send private message

I know there is a quirk to 'expect' that I'm just not picking up on!

Someone please shed some light on it for me!!!!! :)

Create new topic

Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.