Jump to content

atnextc

Active Members
  • Posts

    136
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

atnextc's Achievements

Adventurer

Adventurer (3/7)

0

Reputation

  1. yea i knew about handles vs filenames, i just didn't see where i was doing it. In regards to string between, not sure, so i removed it in the above script and re-ran and still working, so i'll remove it from the other times it exists in my script it was probably one of those, it works so leave it be kinda things. Thanks for the help.
  2. So after reading what you put, i re-read what i put and realized my problem. Moved my filewrite, into the If statement where it belongs, now the line Install FPC into slot 5 only gets written 1 time to the file which is what I was trying to accomplish. if $I >=1 Then If $fpc[0] = fileread("fpc.txt") Then MsgBox(0,$I&" Test",$fpc[0]) fileclose("hardwareadd.txt") Else filewrite("hardwareadd.txt", "Install FPC into slot " & $fpc[0]&@CRLF) fileclose("hardwareadd.txt") EndIf EndIf
  3. kylomas yes, basically i was under the assumption that since I was closing the file hardwareadd.txt, if the contents of it, "in this case 5", matched the array fpc[0] which is also 5 would not be able to be written to. Basically i'm trying to have it look at the array value and the first time through write it to fpc.txt, then on subsequent runs, it will look to see if the value of the array matches the contents of fpc.txt if so then do nothing and by that I mean make it to where the filewrite doesn't happen to hardwareadd.txt, if not then write whatever to hardwareadd.txt. Please let me know if this makes more sense. I'll play with your example and see if its accomplishing what i'm looking for. Thanks for the help. $fpc = _StringBetween($str, "-", "/", 3) ; the 4th parm is true or false, what are you trying to do? What this is doing is grabbing the what is grabbing the first number between - and / in the str which in this case is 5. Is there a better way to grab this information?
  4. So i'm testing this scenario to put into a bigger script. Basically I have an issue where, i have a string i'm evaluating 3 times in this example, and its being written to a file. Then i'm looping it to say if the string matches what's in the file that was written to, to close another file. Bottom line is, my MSGbox testing seems to be working correctly, but my output is produced 3 times in my file instead of only just 1 time. Any help would be appreciated. #include <file.au3> #include <String.au3> $str= "xe-5/1/0" FileDelete("fpc.txt") FileDelete("hardwareadd.txt") $I = 0 Do fileopen("fpc.txt",1) fileopen("hardwareadd.txt",1) $fpc = _StringBetween($str, "-", "/", 3) If $I = 0 Then filewrite("fpc.txt",$fpc[0]) fileclose("fpc.txt") EndIf if $I >=1 Then If $fpc[0] = fileread("fpc.txt") Then MsgBox(0,$I&" Test",$fpc[0]) fileclose("hardwareadd.txt") EndIf EndIf filewrite("hardwareadd.txt", "Install FPC into slot " & $fpc[0]&@CRLF) fileclose("hardwareadd.txt") $I = $I +1 Until $I =3
  5. So ran into another issue semi related. Basically i'm reading a file into an array in 1 function, and its running a certain number of times, lets say 6. The array has lets say 10 items in it. Then I'm reading that same file into another array in another function later on in the script. How can I "pick up" at value 7 and have it loop the remaining 3 times in this example till it reaches the end of the array. I can provide examples of what i've tried if need be. Thanks
  6. well probably not the best method. I was able to do what I needed using: $str = 'set interfaces xe-0/0/6 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 CHGOBPRJ02;xe-0/0/0;MR;10GE TO CHGOBPRJ02;"' $res = StringSplit($str,";",2) Msgbox(0,"", $res[3])
  7. mikell, thanks, what i'm looking for is to parse out only the second interface that is listed in the description which in the sample example provided is xe-0/0/0. I"m not familiar with regex. I imagine there is a way to grab that out using them though.
  8. Melba23 thanks, didn't even notice that. Not sure how that happened
  9. thanks JohnOne For the reply. While it is not erroring, its still not grabbing the correct information for the Zside interface. I believe i've done what you posted above before while trying to get this to work, thinking heck yea finally figured it out. the only thing i'm interested in getting that i can't seem to get properly is in bold below. set interfaces xe-0/0/6 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 CHGOBPRJ02;xe-0/0/0;MR;10GE TO CHGOBPRJ02;" What the script above does is grabs everything between ; and ; and writes that back into the file resulting in the following: set interfaces xe-0/0/6 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 CHGOBPRJ02;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 CHGOBPRJ02;xe-0/0/0;MR;10GE TO CHGOBPRJ02;" what this is essentially doing is copying the "circuitID" field and the "zsiderouter" field 2 times and pasting it back in the file. I've also tried doing an if stringinstr = the above syntax to basically remove the dupes but it didn't resolve the issue. Any ideas are more than welcome i've been working like 20+ hours just trying to get this one stupid part right, and I can't move on with the script unfortunately until this is correct.
  10. yea typo when i put it in there. its not that way in the actual script.
  11. Hey guys, I have a problem I have run into on a script that was going rather well given the limited amount of scripting / programming knowledge that I have. The issue that I have run into seems to be a catch 22 in that I have 2 files which contain router interface commands for our equipment. I basically need to declare a variable in one for loop, and pass that same variable to either another function or another for loop. What I am getting now is "Subscript used with non-Array variable.:" on $asideinterface for the _bside function I"m basically trying to grab this data from both files. Test.txt would be the A side, and Test2.txt would be the Z side. $asideinterface = _StringBetween ($ainput[$a],"interfaces ", " description") $circuitid = _StringBetween ($ainput[$a],"""Cox;",";C4") $zsiderouter = _StringBetween ($ainput[$a],"C4 ;",";") $zsideinterface = _StringBetween ($ainput[$a],";", ";") <-----I'm trying to grab whats between ; and ; towards the end of the file, but i can't tell it not to use the first instance of what it finds using _StringBetween Sample code posted below. Sample code that can be used for "test.txt" and "test2.txt" listed in code. Test.txt: set interfaces xe-0/0/6 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 CHGOBPRJ02;xe-0/0/0;MR;10GE TO CHGOBPRJ02 #1;" Test2.txt: set interfaces xe-0/0/0 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 PROVBBRJ01;xe-0/0/6;MR;10GE To PROVBBRJ01;" #include <file.au3> #include <String.au3> Local $a,$afile, $bfile, $ainput, $binput,$circuitid, $asiderouter, $zsiderouter, $asideinterfaces,$zsideinterfaces $afile = @ScriptDir & "\test.txt" $bfile = @ScriptDir & "\test2.txt" _FileReadToArray($afile,$ainput) _FileReadToArray($bfile,$binput) For $b = 0 To UBound($binput)-1 $zsideinterfaces = _StringBetween ($binput[$b],"interfaces ", " description") $asideinterfaces = _StringBetween ($binput[$b],";", ";") <-----I'm trying to grab whats between ; and ; towards the end of the file, but i can't tell it not to use the first instance of what it finds using _StringBetween if stringinstr($binput[$b],"description") Then filewrite (@ScriptDir & "\bsideinterfaces.txt",$zsideinterfaces[0]& @CRLF) filewrite (@ScriptDir & "\bsideinterfaces.txt",$asideinterfaces[0]& @CRLF) EndIf Next For $a = 0 To UBound($ainput)-1 $asideinterfaces = _StringBetween ($ainput[$a],"interfaces ", " description") $zsideinterfaces = _StringBetween ($ainput[$a],";", ";;") if stringinstr($ainput[$a],"description") Then filewrite (@ScriptDir & "\asideinterfaces.txt",$asideinterfaces[0]& @CRLF) filewrite (@ScriptDir & "\asideinterfaces.txt",$zsideinterfaces[0]& @CRLF) EndIf Next _bside() func _bside() For $b = 0 to UBound($binput)-1 $zsideinterfaces = _StringBetween ($binput[$b],"interfaces ", " description") $circuitid = _StringBetween ($binput[$b],"""Cox;",";C4") ;$circuitid = _StringBetween($binput[$b],";", @CRLF) local $asiderouter = _StringBetween ($binput[$b],";C4 ",";") local $asideinterfaces = _StringBetween ($binput[$b],";", ";")<-----I'm trying to grab whats between ; and ; towards the end of the file, but i can't tell it not to use the first instance of what it finds using _StringBetween if stringinstr($binput[$b],"description") Then _FileWriteToLine(@ScriptDir & "\test2.txt", $b, "set interfaces " &$zsideinterfaces[0]& " description ""Cox;"&$circuitid[0]&";C4 "&$asiderouter[0]&";"& $asideinterfaces[0] &";MR;10GE To " & $asiderouter[0] &";""", 1) EndIf Next EndFunc _aside() func _aside() For $a = 1 to UBound($ainput) -1 $asideinterfaces = _StringBetween ($ainput[$a],"interfaces ", " description") Local $circuitid = _StringBetween ($ainput[$a],"""Cox;",";C4") local $zsiderouter = _StringBetween ($ainput[$a],";C4 ",";") local $zsideinterfaces = _StringBetween ($ainput[$a],";", ";MR;10GE") if stringinstr($ainput[$a],"description") Then _FileWriteToLine(@ScriptDir & "\test.txt", $a, "set interfaces " &$asideinterfaces[0]& " description ""Cox;"&$circuitid[0]&";C4 "&$zsiderouter[0]&";"& $zsideinterfaces[0] &";MR;10GE To " & $zsiderouter[0] &";""", 1) EndIf Next EndFunc Please let me know if I need to be more clear I know this is kind of all over the place. Thanks for any help in advance.
  12. Unfortunately the suggested option of creating the file in the same directory as the script isn't possible neither is the method of looping the file names as is this was just a small posting of the rest of the code which is over 5000 lines and the file names are hard coded for other purposes. But thank you for the reply
  13. Why does the formatting haunt you... I'm open to better was of writing it
  14. Edano every file opened is closed towards the bottom...am I not using file handles I was under the impression that I was
  15. @orbs see updated post. essentially i'm writing a router config, and the way i have to do it is write each part to a seperate file, and then coming them into one complete file, which is copied to the clipboard and pasted into an editbox during another part of the script. I'm just trying to figure out why the files aren't being deleted.
×
×
  • Create New...