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.


slippers

193 posts

Master Geek


#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
slippers

193 posts

Master Geek


  #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





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15



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.