Limiting arrays and using lindex in regexp commands

Hello there,
Here's my second and extremely crap question/post with regards to EEM/TCL.  I've been doing some googling and haven't really been able to find an answer to these questions.  Probably more due to my lack of skill with the search bar than the information just not being out there.  Hope you'll forgive me though.
1.     My first question is this.  Say I want to get some output from a command.  I'd like to see all the interfaces in the "show ip vrf interface command" for example.  Not knowing how many interfaces there might be, there could be 10 or there could be 200, what's the best way of limiting a loop function after I have issued the following commands?
set _vrf_int [exec show ip vrf interface]
set _array_vrf_int [split $_vrf_int "\n"]
set $i 0
while {$i < 200} {
  regexp {([A-Z]+[a-z]+[0-9]+).*} [lindex $_array_vrf_int $i] _complete_string _int
  inc $i 1
Not 100% sure the syntax is correct, sorry.  If I only have 10 interfaces then there isn't going to be a need to issue this loop 200 times for "$_array_vrf_int".  It also wouldn't be great if I went over 200 interfaces.  Is there a way I can limit this loop based on the number of lines that were captured after the split function?
2.    The value of the regexp above is output to the var $_int.  Is there a way I can output the regexp to an array? a'la:-
regexp {([A-Z]+[a-z]+[0-9]+).*} [lindex $_array_vrf_int $i] _complete_string [lindex $_int $i]
Syntax there definitely isn't correct but I guess there might be a way to do this.  Any thoughts?
3.     I've been doing some comparisons on some output to see if an access-list is present on an interface.  I can get a regexp to pull back the name of the access-list on a particular interface but if no access-list exists can I do an if statement on nothing?
set _acl_name 0
regexp {.*ip access-group (.*) in} $_running_int _complete_string _acl_name
if {$_acl_name != 0} {puts "there is a access-list on $_int"} else {puts "there's no acl on $_int :-("}
In the output above I'm setting the value of "$_acl_name" to zero so that I can compare it in the if statement.  This seems like a crap newbie way to do it though.  Is there some kind of wildcard I can put in place of the "0" to match an empty variable. a'la {null}.
4.     Sorry last question.  Can I also reset the variable to {null} using a similar wildcard.  Again I can reset the variable to 0 but it just seems like I don't understand the syntax well enough and there is probably a better method.
5.     I've read several tutorials that cover alot of the basics.  Is there a good reference anyone can suggest so I don't waste any more of your time with these silly questions?  I'm afraid the scripts I've studied on this forum are still way over my head.
Many thanks in advance
Alex

Hi Joseph,
Thanks again for all your help.  Sorry it's taken a while to respond.  If I'm honest, you'd cooked me with your response and I wanted to give your reply some decent time to digest and gain some level of understanding.  It's been a few years since I was 17, learning pascal and I'm finding the whole tcl scripting particularly hard to get my head around.  After the third level of if/for/foreach with nested split commands etc my brain seems to lose the plot.  Never the less I shall persist.
Using the information you've kindly provided I've since got a nice tclsh only script that will look through a routers vrf interfaces, pick out the ones that have a particular vrf, check each one for an inbound access-list, confirm the access-list meets certain criterial based on a switch/regexp function and finally report on lines that shouldn't be there or are missing all together.  The "unset" command wasn't useful in this scenario unfortunately.  It seems to explicitly delete the variable together and so I can't check if it's empty or not.  I've instead resorted to setting the list variable I was using to 0 for all entries before with the switch function that if matched sets an individual entry to 1 before they are checked at the end to ensure they were all matched. I'm sure it's not the most elegant script in the world and due to the extensive use of the "exec" command, I couldn't actually use it.  Still I'm getting there, abiet very slowly.  The hours that I've spent playing with tcl are certainly racking up now.  I just hope my knowledge is too.
Thanks for the suggestion on the book.  I checked and it is indeed the one I purchased 2 years ago when my interest in eem was first captured.  It's unfortunately very thick and slightly scary!  It also doesn't have any examples of combining switch/regexp functions together, which is a bit annoying considering that's the first thing I've tried to use it for.  Hopefully I'll find it very useful as my understanding gets alittle greater though.
Anyway, thank you again for your extremely helpful responses.  Until the next stupid question!
Kind regards
Alex

Similar Messages

  • It appears from my limited research and attempts that symbolic link command in Terminal is broken in 10.8.2

    It appears from my limited research and attempts that symbolic link command in Terminal is broken in 10.8.2
    Can anyone confirm or deny my observation ?

    It appears from my limited research and attempts that symbolic link command in Terminal is broken in 10.8.2
    Can anyone confirm or deny my observation ?

  • Inserting Records in an Array and using a constructor with it

    I badly need help on this! Please please please! I have been studying java for a short time only.
    Anyway, here goes: My project requires the following:
    Employee inputs the no. of video in the shelf. They have four classifications: Drama, Comedy, Action, and Thriller. Each video classification has different rates. The employee creates a video record containing the following information: 1. video ID number, 2. video classification, and 3. Price.
    The employee should display the classifications of videos available and the price. Only the available video tapes would be displayed according to the customer's chosen classification. When the customer chooses the video he wants to rent, the program will register and attach the name of the customer to the video number.
    I only need to use arrays, and NOT database to record the information.

    is it ok i i declare the drama_rate outside the video class?
    i have a list of variables on my videoupdate classYes. It's probably best to declare it static & then you can access it directly:
    public static float drama_rate = 100.0;
    rate = <the class name>.drama_rate;
    so, i should also include a customer no. both in the video and customer class.I would. You may want to list a bunch of videos and who currently has them. This way you don't have to search the customers AND the videos to do this.
    thanks =) i don't know either why we had to validate/invalidate,\
    but our applet doesnt refresh when >it is supposed to, so
    we just used this method. It wouldnt slow down the application, would it?Could you just revalidate()?
    the use of arrays. i havent finished with the program yet.
    i have the design already, i just couldnt put it in code.
    im not familiar with the use of multidimensional arrays-
    can i use this for the video and customer records i will need to store?Not sure what you're using arrays for, but here's an example of something I might do. Maybe it will be useful to you.
    Have you looked at HashMaps? You could use "Customer" as the key and then use an ArrayList of checked out Videos as the value:
    HashMap customers = new HashMap();
    ArrayList videos = new ArrayList();
    //Add the checked out videos to the list
    videos.add(video);
    <etc>
    // Add this customer and the list of videos he has checked out.
    customers.put(customer,videos);
    [\code]

  • Storing data in arrays and using Stirng methods

    Hi There!
    Could any one help me in developing a kind of "PhoneBook" in java?
    Coding for the following program is required in java(jdk1.2).
    The problem is to program a PhoneBook in the following way when the program executes
    A list of following option will be displayed for the user to select from
    a- Enter new Name/Phonenumber
    b-Delete an Entry from the PhoneBook
    c- Dispaly the existing Data(Names with associated
    PhoneNumbers.
    d-Exit the program
    Based on the options selected by the user , the program will perform required task
    The data will be stored in arrays of some kind.
    To perfom the functions selected by the user String methods (charAT(), indexOf etx) will be used
    For search function character search is allowed e.g if the user enters the name "Smith" whose phonenumber will be searched for in the PhoneBook, after enterin just "sm", all the enteries starting with sm and their associated phonenumbers will be displayed.
    The records will be displayed in the following way
    a Smith 111-4444
    b Albert 222-6666
    Please help me I will be very thank ful.

    Shall we say 'its' instead???
    From the format of its post...
    Doesn't sound really good, but if the female are
    offended...
    :-)Well ... we had that once before ... she was offended .. kinda .... Don't know about Saadia ... so far she's looking for a solution I guess, once she has that .. than she'll think about "other" things! :-)
    But to answer your question, you can use he/she. Is that too much extra typing? I guess, the posters also can add a (Mr./Miss) to their names ... if they care ... actually that's what I suggested this other lady to do! :-)
    (Mr.) Kamran Aftab

  • Clarification on how to find region id, and use it with $a_report command

    Hi, I am new to javascript, so bear with me. :)
    we have a tree called species that expands to allow users to select a particular type of fish species. This tree lies in a region called SPECIES.
    the species that a user has selected populate a report which is comprised of a collection and is in the region FAVORITES.
    I have created the hidden variable P900_REPORT_ID and placed it in the region FAVORITES.
    in the footer region of FAVORITES I have the following:
    <script type="text/javascript">
    $s('P900_REPORT_ID',value) = '#REGION_STATIC_ID#'.substr(1);
    </script>
    and finally, in the after header region I have javascript including:
    function addCollection(pValue,r,s,t)
    var get =
    new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=add900ToCollection',0);
    get.add('P110_SELECTED_NODE',pValue);
    gReturn = get.get();
    get = null;
    $a_report('P900_REPORT_ID','1','15','15');
    It does not appear that P900_REPOR_ID is ever populated. The tree does appear, the nodes expand, the user selects a species, and then the tree collapses completely without populating the collection FAVORITES.
    again, I am so new to javascript that I am not certain if I am explaining properly...and thoughts?

    I have modified the region footer in FAVORITES to be:
    $s('P900_REPORT_ID','#REGION_STATIC_ID#'.substr(1));
    </script>
    and modified the javascript for ADDCOLLECTION to:
    $a_report($x('P900_REPORT_ID').value,'1','10','100');
    this appears to work, but just received the following error. Do any of you have experience with this? thanks again? Karen
    Checksum error for Hidden and Protected item ID (84072206841759984), value (314246866896649185), posted checksum (5BD5912E5426E28CF0F87946112B0937), expected checksum (********************************), index_i (14), index_j (2), index_m (9);
    Return to application.

  • Hi! can any1 pls let me know how to create a look up table in labview and use that in the vi.

    hello !
    i have no idea how to build a lookup table(as v use in microcontroller) in labview and use that in vi.pls help me
    txs
    nitin
    Solved!
    Go to Solution.

    If the lookup table is always going to remain the same (e.g. a character generator or something similar) you can place the values in a 2D array constant on your diagram, with the input value as one column, the equivalent as the other. When you need to perform the lookup you use an index array to return all the values in the "input column", search it using "search 1D array" and use the resulting index number to index the other column's data. If the values may change, then it would probably be best to load an array control with your equivalent values from a file.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • I can no longer use the keyboard shortcuts, 'command  C' and 'command   V'.  Did I inadvertently do something to my keyboard or computer that caused this?  Is there a way to fix it?

    I can no longer use the keyboard shortcuts, 'command  C' and 'command   V'.  Did I inadvertently do something to my keyboard or computer that caused this?  Is there a way to fix it?

    You can also check in System Preferences > Keyboard > Keyboard Shortcuts, make sure that custom shortcuts were not created using those same commands. If ones were, they could be creating a conflict. Step throuogh each of the items in the left list, checking the array presented in the right pane for each.

  • Build array within scriptblock and use outside the block

    Hi,
    I am using scriptblock to run several commands in parallel. The code working fine. BUT I am trying to build an array of object within the scriptblock. My aim is to have all execution results in one array and after exiting the script block to print the results
    from all run. I notice that what i build within script block getting destroyed and in the end the $result variable is null. Is there any way that I can build and accumulate the results in a variable and use that outside scriptblock?
    code:
    $result= @()
    ForEach ($Command in $Commands)
        While (@(Get-Job -state running).count -ge $MaxThreads){      
        Start-Sleep -Milliseconds $SleepTimer
        Start-Job -scriptblock {
    $n = $Command
    $result += New-Object Psobject -property @{DATE = (Get-Date -format "MMddyy"); RESULT = $n}
        } -ArgumentList $Command -Name "$($Command)job" | Out-Null
    While (@(Get-Job -State Running).count -gt 0)
        Start-Sleep -Milliseconds $SleepTimer
    ForEach($Job in Get-Job)
        Receive-Job -Job $Job
        Remove-job -Force $Job
    $result

    Yep, but my real problem is that every now and again I just can't help myself and end up feeding the troll.
    I've had plenty of fun recently watching it twist in the wind and blather on about absolutely nothing of any substance. I'm assuming we'll get another missive across these threads later (dance puppet, DANCE)...
    The real shame though is when it ends up attacking the poor random OPs for asking a question. We're used to dealing with it so I can laugh at the situation, but it does bother me that the people who are just out looking for help end up getting lambasted
    by some complete jerk.
    I'm going to keep on ignoring it, hopefully if we all just stop playing along it'll get tired and go be useless somewhere else.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)
    Offensive as he (?) can often be, it is difficult to take his attacks personally, because he obviously has no clue what (or who) he is talking about.
    What bothers me more about this phenomenon is:
    the disrespect shown to people just looking for help;
    the impact on the effectiveness of the forum with all the time and space wasted for no purpose;
    the troll himself, who seems to either be suffering some kind of emotional or personality disorder, or is playing some kind of game without concern for its effect.
    He doesn't get much positive feedback here, so perhaps he just feels that being able to write the way he does in a public forum, and get some response, is enough to prove his worth to his ego. Unfortunately, we will probably never find out more about him
    than is evident from his posts.
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.
    Seems to be a "tagger" mentality.  Marking territory with acts of vandalism.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • What is the difference between 'command delete' and using 'delete original and all versions'?

    My masters are not referenced and I usually have only one version.  What is the difference between using 'command delete' versus going to the top menu bar and using 'dele

    Good question  .
    When the Version is the only Version based on the Original of that Version, the two commands have the same effect.
    See this User Tip by master Aperturist Frank Caggiano.

  • Using an array within an array, and exporting to CSV

    I am gathering data about an AD user, including group membership and I want to output that to a CSV. Easy enough right? Not so much :) I am successfully generating 2 arrays, one has user data and the 2nd has group membership, but it's not exporting properly
    to CSV. I've tried the -notypeinformation but it's still showing up.
    My code is below, followed by contents of CSV file in text format.
    cls
    #declare array to use
    $user_main = @()
    $arrGroups = @()
    $user = Get-ADUser -Filter {samaccountname -eq "MyUserName"} -Properties *
    $temp_user.Name = $user.Name
    $temp_user.SAMname = $user.SamAccountName
    $temp_user.lastpwchange = $user.PasswordLastSet
    $temp_user.lastlogon = $user.LastLogonDate
    #get group membership
    $groups = $user.memberof
    foreach ($group in $groups)
    $temp1 = $group.Split(",")
    $group_name = $temp1[0].Substring(3, $temp1[0].Length -3)
    #$arrGroups += New-Object -TypeName psobject -Property $temp
    $arrGroups += $group_name
    $user_main += New-Object -TypeName psobject -Property $temp_user
    #$user_main | select * | Format-Table
    #$arrGroups
    $new = $user_main + $arrGroups
    Export-Csv -InputObject $new -Path c:\test\test.txt -NoTypeInformation -Encoding "utf8"
    Write-Host ""
    Write-Host "Done"
    The resulting text file contains:
    "Count","Length","LongLength","Rank","SyncRoot","IsReadOnly","IsFixedSize","IsSynchronized"
    "45","45","45","1","System.Object[]","False","True","False"
    So I have 2 issues. One is the "export-csv -notype" isn't working quite right, not sure why. And secondly, you can see the System.Object[] entry, which I believe is my array of groups. I need that to display the names of the groups the user belongs
    to.
    Any help is greatly appreciated!

    Hi Robert,
    I’m writing to just check in to see if the suggestions were helpful. If you need further help,
    please feel free to reply this post directly so we will be notified to follow it up.
    If you have any feedback on our support, please click here.
    Best Regards
    Anna
    TechNet Community Support

  • Crystal report SQL Command and using IN

    Post Author: geozuh
    CA Forum: Crystal Reports
    Does any one know how to get a multiple value prompts to work in Crystal report SQL Commands? I have an extremely large database and do not want to pull back all the records to the report. I know I can do the filtering in the report, but due to the size of the database, I am restricked from doing do.
    I would like to set the State as a multiple value parameter/prompt to be used in the SQL Command.
    Ex.
    Select CustID, FirstName, LastName
    from Customer
    where State in ('WI', 'IL', 'MN') --this would be turned into a parameter

    Post Author: yangster
    CA Forum: Crystal Reports
    you are over thinking the problemsimply create a parameter within crystal for your state and change it to allow multiple valuesthen in the select expert put in state = ?stateif you do show sql query you will see that the values are pushed down to the sql level thus no performance hit vs putting the parameter directly in the command itself

  • How to create and use mutable array of UInt8

    Hello!
    If I get it right, UInt8 *buffer, buffer - is a pointer to a start of array?
    Then how to create and use mutable array of UInt8 pointers?
    The main target is a creation of the module that will store some byte array requests and will send all of them at the propriate moment.

    I try
    - (void) scheduleRequest:(UInt8 *)request {
    if (!scheduledRequests) scheduledRequests = [[NSMutableArray array] retain];
    [scheduledRequests addObject:request];
    But get warning:"passing argument 1 of 'addObject:' from incompatible pointer type"

  • I am having mac book air 2012model i had installed mavericks and use it, i long press command and power button at a same time and i saw the command prompt, from that i had formated the total hard disk. how to i want to install the OS again ?

    I am having mac book air 2012model i had installed mavericks and use it, i long press command and power button at a same time and i saw the command prompt, from that i had formated the total hard disk. how to i want to install the OS again ?
    i tryed with download mavericks but finally its saying a error message like cant conect to istore like that its saying and every thing is clear like internet and other stuf i tryed with 3times no progress same error pls help.. i bought this lap for my bro with his apple id only we use it now he got a new mac book pro so he gave to me so i formated and use it i use my apple id is that problem come because of changing apple id ? pls eplain

    Firstly, what is the source of the 10.6.4 disc? Is it the original installation disc for your MacBook, or one 'borrowed' from another computer?
    It isn't the retail version, because that's 10.6.3.
    Assuming it's the correct disc (i.e. the one that shipped with your Mac), you need to boot from it again.
    OK the language page.
    From the installer screen, ignore the continue button, go to the menu bar and choose Disk Utility from the Utilities menu.
    In DU, select your internal drive in the sidebar (the top item with the makers name and serial no.).
    Run Repair Disk. If that comes up as disk OK, click the partition tab. Select the partiton from the drop-down above the graphic; 1 partiton is all you need.
    Go to the options button and ensure that the partition scheme is GUID and the file system to Mac OS Extended (Journalled). Name the partiton (usually Macintosh HD), click Apply.
    When the Macintosh HD volume appears below the drive name, quit DU and see if you can then install.
    If the screen after the language screen doesn't show the menu bar, it may be necessary to use another Mac to do the job with the MB in Firewire Target Disc Mode. If it won't boot in TDM, or the MB doesn't have FireWire then it's getting very difficult.

  • Could not save Preferences because the file is locked, you do not have necessary access permissions, or another program is using the file. Use the 'Get Info' command in the Finder to ensure the file is unlocked and you have permission to access the file.

    I have this massage every time close ps cc
    Could not save Preferences because the file is locked, you do not have necessary access permissions, or another program is using the file. Use the ‘Get Info’ command in the Finder to ensure the file is unlocked and you have permission to access the file. If the problem persists, save the document to a different file or duplicate it in the Finder.

    You may get better help in Photoshop General Discussion
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll
    If FINDER means Mac, read below (and try to give more information when asking a question)
    Mac 10.9.3 workaround https://forums.adobe.com/thread/1489922
    Enable Mac Root User https://forums.adobe.com/thread/1156604
    -more Root User http://forums.adobe.com/thread/879931
    -and more root user http://forums.adobe.com/thread/940869?tstart=0

  • Mapviewer map_request limitations for when using wms and jdbc themes?

    Are there limitations to not use either the bounding_themes or the center option when a basemap requests both a jdbc and a wms theme? I would like to have the bounding_theme be the jdbc theme. I can see how this could pose challenges in that there would be a need to retrieve the jdbc theme and calc the mbr before issuing the wms requests w/ the correct bbox. Would be a nice feature though.

    woops, sorry LJ -- it works. Do you have suggestions though for dealing w/ case where the jdbc theme returns one point? id like to use something like the border_margin to pad the point out to a box, but seems to always just return just the point. mkaes sense since multiplying 0 by anything is zero. we are planning on writing a servlet that instead uses sdo_buffer then construct the coordinates tag w/ the sdo_aggr_mbr. that should accommodate 1..n points returned.
    <bounding_themes border_margin="0.05">

Maybe you are looking for

  • Apex 3.1.2 Development Environment typo

    <ol> <li>On the Report Attributes tab of a report...</li> <li>in the Layout and Pagination      section...</li> <li>the field label "Report Attributes Substituion"</li> </ol> I'm thinking there's a 't' missing there. Yet how many times have we all gl

  • Everytime I open itunes it says do you want to allow this program to make changes to your computer

    It opens but it's annoying as **** it never did it when I when I first bought it

  • Reverts back to dark gray login screen and will not allow me to login

    HI! SPECS  Retina 15in. 16gb of memory 500 gb ssd. OS - Mavericks PROBLEM I can boot up and login to my laptop - no problem. I have my login set up so that my user name appears and all I have to do is type my password. The problem is when I try to wa

  • White Background Image how do I take off?

    Hey guys, recently I made my first project and it looks like this: https://www.youtube.com/watch?v=hXQEDreFoe4 Problem im thinking of doing the same concept but I dont want the white background of the image. Does anybody know how I can erase the whit

  • Compressor 4

    Please Please what am I doing wrong? I know it is all my lack of understanding-it still does not work. l am try to publish or share or whatever a project I finished and compressed about 1 and 1/2 months ago to facebook. I have it codec in MPEG 4 I gu