CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Re: [FishMonger] Script to remove features of a subscriber line.: Edit Log



cuboidgraphix
User

Jan 8, 2009, 1:29 PM


Views: 5438
Re: [FishMonger] Script to remove features of a subscriber line.

One slight modification guys... I had to move the OPEN WRITE into the IF statement, because I noticed that the numbers weren't getting written into the data_numbers.txt.

I still don't know what you mean by 'next unless ...' FishMonger, but thanks for everything so far bro.


This is the current WORKING script:


Code
#!/usr/bin/perl 
# This is a script that will telnet into a telcom switch,
# query a subscriber's number (sn) and check if the sn has
# data service in the account.

use strict;
use warnings;
use Net::Telnet;

my $user="user";
my $pass="pass";
my $server="host";
my $t = Net::Telnet->new($server);
$t->waitfor('/Enter User Name/');
$t->print("$user");
$t->waitfor('/Enter Password/');
$t->print("$pass");

# Open LIST, to read the subscriber numbers in list.txt.

open(LIST, "list.txt")
or die "Can't open 'list.txt' $!";

while(my $number = <LIST>){
if($number =~ /^6|^2/){
print "The number is: $number\n";
$t->waitfor('/>/');
$t->print("qhlr $number");
$t->waitfor('/>/');
$t->print("");

# Capturing the output.

my ($output) = $t->waitfor('/>/');
print "The output is: $output\n";


# Ouput is striped of \n and converted into a single line.

$output =~ s/\n//g;


# Checking the single line if it contains CSO: or QOPSI:.
# If match it is found, then the number is written into data_numbers.txt.
# If not found, while loop prints a spacer of --- then it goes to the next number.

if($output =~ /CSO:|QOSPI:/){
print "The number has Data Service.\n";

# Open WRITE, data_numbers.txt to write in the subcriber number that has the data service.

open(WRITE, ">>data_numbers.txt")
or die "Can't open 'data_numbers.txt' $!";
print WRITE $number;
close WRITE;
} else{
print "The number does NOT have Data Service.\n";
}

print "-------------------------------------------\n";
}
}

close LIST;

# After all numbers in the loop have been queried, the session is closed.

$t->print("quit all;logout");
print "The Session has Ended!\n";
$t->close;



(This post was edited by cuboidgraphix on Jan 8, 2009, 1:42 PM)


Edit Log:
Post edited by cuboidgraphix (User) on Jan 8, 2009, 1:30 PM
Post edited by cuboidgraphix (User) on Jan 8, 2009, 1:34 PM
Post edited by cuboidgraphix (User) on Jan 8, 2009, 1:35 PM
Post edited by cuboidgraphix (User) on Jan 8, 2009, 1:37 PM
Post edited by cuboidgraphix (User) on Jan 8, 2009, 1:42 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives