4.8 External Credit Check/Recharge Script

2N® SIM Star Server provides a possibility to define a custom script for SIM cards' credit check and recharging. This feature enables you to create a script of your own for USSD answers. 

Caution

  • Using this feature may lead to a credit check/recharge function error!
  • You are recommended to use the scripts that have been completely tested on a test site!

External scripts are used for advanced search values in the text. It can be any executable file located in the /usr/simstar/scripts directory. You can use a compiled binary program, shell script, perl or php, for example. The file must be set as executable for the user "simstar". The file name length is limited to 15 characters. The script name is entered in the configuration. The text is during start-up script passed as the first parameter. The second parameter is the IMSI and the third one SCID of the used SIM card. The phone number of the SIM card is passed as the fourth parameter. The script has to write a search result to the output (stdout). The result may include more values. Each value must be on a separate line. The line format is "VARIABLE:VALUE".

List of variables:

  • SKIP – skip result of script
  • RCRD – remaining credit for prepaid card
  • RCR2 – remaining credit (decimal part of cost) for prepaid card
  • UCRD – used credit for prepaid card (last call)
  • UCR2 – used credit (decimal part of cost) for prepaid card (last call)

External Script Examples

BASH Example:

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

#!/bin/sh
  1. Get USSD string.

    str=$1
  2. Replace these two lines by analysis of $str and setting real values.

    rcrd=123
    rcr2=45
  3. Print the required values for the handover to SIM Star Server.

    echo RCRD:$rcrd
    echo RCR2:$rcr2

–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 

PERL Example:

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

#!/usr/bin/perl
  1. Get USSD string.

    $str = print $ARGV[0];
  2. Replace these two lines by analysis of $str and setting real values.

    $rcrd = 123;
    $rcr2 = 45;
  3. Print the required values for the handover to SIM Star Server.

    print "RCRD:".$rcrd."\n";
    print "RCR2:".$rcr2."\n";

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––