Created
September 26, 2013 02:48
-
-
Save askinss/6709223 to your computer and use it in GitHub Desktop.
subscriber imsi fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/telnet' | |
HOST = '172.23.1.100' | |
PORT = '10050' | |
USERNAME = 'BBBMW' | |
PASSWORD = 'BBBMW' | |
def get_imsi(msisdn, &block) | |
ema = Net::Telnet::new("Host" => "#{HOST}", | |
"Port" => "#{PORT}", | |
"Timeout" => 10, | |
"Prompt" => /Enter command:/) | |
ema.cmd("LOGIN:#{USERNAME}:#{PASSWORD};") | |
ema.waitfor(/Enter command:/) | |
resp = ema.cmd("GET:HLRSUB:MSISDN,#{msisdn}:IMSI;") | |
resp = resp.match(/RESP:(?<respcode>\d+):MSISDN,(?<msisdn>\d+):IMSI,(?<imsi>\d+);/) | |
block.call([resp[:msisdn], resp[:imsi]]) | |
end | |
imsii = Array.new | |
f = File.open("/home/bblite/subscr.txt") | |
f.each_line{|line| imsii << line} | |
def get_imsis(imsii) | |
File.open("/home/bblite/subscriber_query.sql", "ab") do |file| | |
begin | |
array_of_msisdns.each do |msisdn| | |
get_imsi(msisdn) { |msisdn_and_imis| file.puts("update subscriber set imsi = #{msisdn_and_imis[1]} where msisdn = #{msisdn_and_imis[0]}")} | |
end | |
rescue | |
retry | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment