Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not sure

Status
Not open for further replies.

sharook

Programmer
Aug 22, 2006
21
US
Gents,

This one seems to be giving me some trouble and I was wondering if anyone could give me a hand. I wrote a different script than the one below that goes into a system and gathers all kinds of specific data on a lot of different items. After I have gathered that data, I want to go back, parse the items from the file and then put them back in the system exactly how they came out. Sounds wierd, but it's just one of those things. However, I am running into a couple of different problems.

1. When I first started the script, I had the strtok for the POTS portion on top of the if and everything except for sNode worked great. When I moved it and included a different type, TO, it doesn't to any parsing. I thought it would work this way, but I guess I'm wrong.

2. My second problem is parsing sNode. I can't seem to get it. Essentially, you get one instance of sNode in the original capture file and then you get all of the settings for that type of circuit for that particular node and then you move onto the next node and so on and so forth. More or less, I need the node to be unique and must capture that string.

proc ProvFacsCircs

string sTemp = ""
string sLine = ""
string sNode = ""
string sType = ""
string sShelf = ""
string sSlot = ""
string sCircuit = ""
string sBtc = ""
string sFrd = ""
string sCmp = ""
string sGn = ""
string sImp = ""
string sCircuitTo = ""
string sSealC = ""
string sRxImp = ""
string sTxImp = ""
string sRxGain = ""
string sTxGain = ""
string sMode = ""

fopen 0 "C:\Program Files\Symantec\Procomm Plus\Capture\test.cap" READ TEXT

transmit "34^M"

while not feof 0
fgets 0 sLine

if strfind sType "POTS"

; These are the tokens for the exact locations and settings of the POTS circuits.

strtok sNode sTemp "RDTx]: " 1
strtok sType sLine " -" 1
strtok sShelf sLine "- " 1
strtok sSlot sLine "-GP " 1
strtok sCircuit sLine "-CKT " 1
strtok sBtc sLine " " 1
strtok sFrd sLine " " 1
strtok sCmp sLine " " 1
strtok sGn sLine " " 1
strtok sImp sLine " " 1

;Provision the POTS Port settings now.

transmit "2^M"
transmit "1^M"
transmit "PHYS^M"
waitfor " Node [^[[7mCDT^[[m, RDTx]: "
transmit sNode
transmit "^M"
waitfor " Shelf# [^[[7m1^[[m-15]: "
transmit sShelf
transmit "^M"
waitfor " GP Slot [^[[7m1^[[m-20]: "
transmit sSlot
transmit "^M"
waitfor " POTS Port [^[[7m1^[[m-8 ]: "
transmit sCircuit
transmit "^M"
waitfor " System Gain [ ^[[7m-2^[[m, 0 ]: "
transmit sGn
transmit "^M"
waitfor " Impedance [600, ^[[7m900^[[m]: "
transmit sImp
transmit "^M"

; Provision the POTS Port DS0 settings now.

transmit "4^M"
transmit "1^M"
transmit "PHYS^M"
waitfor " Node [^[[7mCDT^[[m, RDTx]: "
transmit sNode
transmit "^M"
waitfor " Shelf# [^[[7m1^[[m-15]: "
transmit sShelf
transmit "^M"
waitfor " GP Slot [^[[7m1^[[m-20]: "
transmit sSlot
transmit "^M"
waitfor " POTS Port [^[[7m1^[[m-8 ]: "
transmit sCircuit
transmit "^M"
waitfor " Blocked Terminating Call [C, ^[[7mD^[[m]: "
transmit sBtc
transmit "^M"

elseif strfind sType "TO"

; These are the tokens for the exact locations and settings of the TO circuits.

strtok sNode sTemp "RDTx]: " 1
strtok sType sLine " -" 1
strtok sShelf sLine "- " 1
strtok sSlot sLine "-GP " 1
strtok sCircuitTo sLine "-CKT " 1
strtok sSealC sLine " " 1
strtok sRxImp sLine " " 1
strtok sTxImp sLine " " 1
strtok sRxGain sLine " " 1
strtok sTxGain sLine " " 1
strtok sMode sLine " " 1

;Provision the TO Port settings now.

transmit "2^M"
transmit "3^M"
transmit "PHYS^M"
waitfor " Node [^[[7mCDT^[[m, RDTx]: "
transmit sNode
transmit "^M"
waitfor " Shelf# [^[[7m1^[[m-15]: "
transmit sShelf
transmit "^M"
waitfor " GP Slot [^[[7m1^[[m-20]: "
transmit sSlot
transmit "^M"
waitfor " TO Port [^[[7m1^[[m-4 ]: "
transmit sCircuitTo
transmit "^M"
waitfor " 3 - SINK ]: "
transmit sSealC
transmit "^M"
waitfor " TO Mode [ 2wire,^[[7m4wire^[[m]: "
transmit sMode
transmit "^M"
waitfor " Rx Impedance [^[[7m600^[[m, 1200]: "
transmit sRxImp
transmit "^M"
waitfor " Tx Impedance [^[[7m600^[[m, 1200]: "
transmit sTxImp
transmit "^M"
waitfor " Rx Gain [ +8.5 to -16.0, ^[[7m +0.0^[[m]: "
transmit sRxGain
transmit "^M"
waitfor " Tx Gain [ +7.0 to -17.5, ^[[7m +0.0^[[m]: "
transmit sTxGain
transmit "^M"

endif
endwhile

waitfor ">" forever
transmit "^["
waitfor ">" forever
transmit "^["
waitfor ">" forever
transmit "6^M"
waitfor "Logon:"
transmit "`r`nThe script is complete. Please verify all settings.`r`n"

fclose 0
endproc
 
Can you post a sample of your data?

Specifically a sample of a 'POTS' record.

What you have above looks technically correct, but without seeing your dataset, it's difficult to test your code.
 
Here a small snippet...As I mentioned, I need to grab the node, hold on to that and use it for all my POTS records and then when a new node shows up, begin using that one.

Retrieve Circuit Settings...
Circuit Type[ 1 - POTS,
2 - DDS,
3 - TO,
4 - POTSR4E,
5 - UVG\C,
6 - UVG\R,
7 - COIN ]1
Node [CDT, RDTx]: cdt
Shelf# [*, 1-15]: *

CDT 06-11-14 17:37:18
M 1016 COMPLD
CDT Aid BTC FrD Cmp Gn Imp
------------------ --- --- --- -- ---
POTS-02-GP01-CKT1 D Yes Yes -2 900
POTS-02-GP01-CKT2 D Yes Yes -2 900
POTS-02-GP01-CKT3 D Yes Yes -2 900
POTS-02-GP01-CKT4 D Yes Yes -2 900
POTS-02-GP01-CKT5 D Yes Yes -2 900
POTS-02-GP01-CKT6 D Yes Yes -2 900
POTS-02-GP01-CKT7 D Yes Yes -2 600
POTS-02-GP01-CKT8 C Yes Yes -2 600

Retrieve Circuit Settings...
Circuit Type[ 1 - POTS,
2 - DDS,
3 - TO,
4 - POTSR4E,
5 - UVG\C,
6 - UVG\R,
7 - COIN ]1
Node [CDT, RDTx]: rdt1
Shelf# [*, 1-15]: *

Main > Provisioning > Circuits Menu
1 - Retrieve Circuit Settings
2 - Edit Circuit Settings
CDT>1

Retrieve Circuit Settings...
Circuit Type[ 1 - POTS,
2 - DDS,
3 - TO,
4 - POTSR4E,
5 - UVG\C,
6 - UVG\R,
7 - COIN ]1
Node [CDT, RDTx]: rdt2
Shelf# [*, 1-15]: *

CDT 06-11-14 17:37:31
M 1017 COMPLD
CDT Aid BTC FrD Cmp Gn Imp
------------------ --- --- --- -- ---
POTS-01-GP17-CKT1 D Yes No -2 900
POTS-01-GP17-CKT2 D Yes No -2 900
POTS-01-GP17-CKT3 D Yes No -2 900

 
Code:
if strfind sType "POTS"

Should sType be sLine?

I don't see where you've assigned the data from your file to the value sType.
 
Great catch kodr. The only thing left is to figure out how to grab sNode. Any ideas? I am back working on this again and will post if I find a solution.
 
I'm kind of confused as to the following:

Code:
if strfind sLine "POTS"

The string 'POTS' appears in several different contexts in your source data.

Code:
Circuit Type[ 1 - POTS,
4 - POTSR4E,
POTS-01-GP17-CKT1  D  Yes  No -2 900

Wouldn't the if statement be true for any of these three? I believe that the 'POTS-01-GP17-CKT1 D Yes No -2 900' data is what you're looking for. Is this correct?

Would it be better to use the following?

Code:
if strfind sLine "POTS-"

For sNode, add an if statement before your check for "POTS-", so that it looks for that first. That way, I believe, it will add a value to sNode first, and only change after an new node is encountered.

Code:
if strfind sLine "RDTx]:"
     strtok sNode        sTemp "RDTx]: " 1
endif
 
I changed the sType to sLine as you suggested earlier and also found that I ran into the redundant instances of "POTS". So, I had already changed that to "POTS-" as you have mentioned and it is working better now. I also tried adding the if statement as you said and it doesn't work. I do a simple usermsg to verify and it comes up blank. So, no luck on that so far.
 
Just found it. One minor change.

if strfind sLine "RDTx]: "

strtok s1 sLine "Node " 1
strtok sNode sLine "RDTx]: " 1

endif

Thanks again for catching my goofups. By the way, how do you do the code insert? I'll post the final when it is complete.
 
Without spaces:

[ c o d e ]
[ / c o d e ]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top