Hi guys, I'm back .... and as promised, this is one of my scripts. Which has been very useful to me. What this script basically does is, log into a 'switch' and removes roaming features off a subscriber line. The subscriber line is located in the roamers.txt . This is very useful when you got thousands of subscriber lines that you need to remove a feature on. This can be modified to not only remove a roaming or other feature, but also to add a feature to a subscriber line.

It's not a very professional script, but it got the job done. The script is as follows.

Re: [FishMonger] Script to remove features of a subscriber line.
[In reply to]

Can't Post

I'm using the for loop because the roamers.txt file has thousands for numbers.. each line has a number. and 6 is the start of each line. an example of numbers would be.. 6701050 6701055 6701074 ... and so on.

I know the script needs the warnings and strict pragmas, I know that now... I was simply posting one of my scripts which I promised I would in my other thread where I needed help, where by you said..

"Don't be too concerned about that at this point; it takes time to learn. When I first started out helping on the Perl forums, my code was functional, but pretty poor quality."

Anyways.. I was just trying to give something back to the forum for all the help I've gotten. Maybe this script can be useful to someone with some modifications and good perl practices.

As for having way too much I/O going on... I couldn't think of any other way of doing it. What I needed was a way to capture the output and verify the output. And my IF conditions would take the next step depending on the Match.

I wanted to write it simpler, but couldn't and honestly, the script does work perfect so far. I ran it for 65,000 + subscriber lines and they all were successfully modified.

I know the script needs a lot of work ... cleaning it up and such.. but I just hope my contribution would help someone with a similar problem I had before I wrote this script.

Anyways.. thanks again for everything. As for cleaning it up.. I'll leave it to the poor soul who wants to use it. :)

Re: [FishMonger] Script to remove features of a subscriber line.
[In reply to]

Can't Post

Hi FishMonger, I'm sorry to disappoint you, my intention was not to say that I didn't appreciate your comments. You are right. If I'm to contribute something to the community, I should contribute something worth contributing.

Well ... I'm actually working on a similar script, and I am practicing good Perl Standards ... but I still can't get around the I/O of the text files. That's honestly the only way I know how to do it. I have tried the approaches suggested, but I am stumped.

Let me give you a brief description of what my purpose is.

I want to log into the switch and run a query. That output on the screen I want capture into a text file (or some other method) and check the file to see if it has a certain string of text.

My approach involves the following:

Open a text file and print the output to it and save. Close it. Open the text file again, remove the \n and make it into one single line and save.. close it. Open the text file again to read and find a match of a string of text. After that I start with my IF statements. Then close it.

Honestly, I know it's not a really good way of doing it.. I've tried incorporating everything into one and it doesn't work for me.

If you could give me another approach I am all ears and would really try to go that route.

Anyways, I apologize to you and the Perl community for seeming like a ungrateful bastard.

I'm stumped ... is that what you meant when you said the output to a variable? I was reading and reading all yesterday and today.. and I saw writing into memory as a variable.. OH well.. I see how simple it was ... yet how complicated it all seemed to me at first.

# Checking the single line if it contains CSO: or QOPSI:. # If match 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"; print WRITE $number; } else{ print "The number does NOT have Data Service.\n"; }

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

close LIST; close WRITE;

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

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