Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9064529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:16:42+00:00 2026-06-16T16:16:42+00:00

Hello I am working on a small script that will allow me to parse

  • 0

Hello I am working on a small script that will allow me to parse information from an input. This is working, but i Know that there is a better way to have done this. Please, I am trying to learn [self taught] so tear me up. The input would be as follows:

C7-0-4-U1   36.5 mHz    IN7-0-4-0   567 mHz 00:15:d0:e3:b0:41   online(pt)  10.106.156.129  42.0    -0.5    35.1    -3.0    38.7    0.0E+000    0.0E+000    9   0    12:20:32 AM    rZ5 1       


C7-0-4-U1   36.5 mHz    IN7-0-4-0   567 mHz 2c:9e:5f:de:ed:36   w-online(pt)    10.113.52.11    36.5    0.0 35.1    -5.0    37.7    4.9E-006    0.0E+000    9   0    12:20:32 AM    r4G 0       


C7-0-4-U1   36.5 mHz    IN7-0-4-0   567 mHz e4:83:99:6d:57:ad   w-online(pt)    10.113.45.239   43.5    0.0 35.1    -4.6    39.5    5.8E-006    0.0E+000    8   0    12:20:34 AM    r4G 0       


C7-0-4-U1   36.5 mHz    IN7-0-4-0   567 mHz 3c:75:4a:9c:7b:92   w-online(pt)    10.109.238.61   42.2    -0.5    33.9    -14.4   34.6    4.9E-006    0.0E+000    199 4    12:20:33 AM    rC2 0       

The Desired Output would be as follows:

00:15:D0:E3:B0:41     10.106.156.129
2C:9E:5F:DE:ED:36     10.113.52.11
E4:83:99:6D:57:AD     10.113.45.239
3C:75:4A:9C:7B:92     10.109.238.61

The Code that I have is as follows:

#GET INPUT FROM CLIPBOARD
set Input [sh_set clipboard]
#REMOVE ALL EXCESSIVE WHITESPACE
regsub -all {\s{3,}} $Input "\n" CleanInput
#SET THE INPUT AS LIST
set List [split $CleanInput "\n"]
#GET LIST ITEMS
set Cust1 [lindex $List 1]
set Cust2 [lindex $List 2]
set Cust3 [lindex $List 3]
set Cust4 [lindex $List 4]
regexp -all {(?:[[:xdigit:]]{2}([.-:]))(?:[[:xdigit:]]{2}\1){4}[[:xdigit:]]{2}} $Cust1 C1MacAddress
regexp -all {10\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){2}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)} $Cust1 C1IpAddress
regexp -all {(?:[[:xdigit:]]{2}([.-:]))(?:[[:xdigit:]]{2}\1){4}[[:xdigit:]]{2}} $Cust2 C2MacAddress
regexp -all {10\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){2}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)} $Cust2 C2IpAddress
regexp -all {(?:[[:xdigit:]]{2}([.-:]))(?:[[:xdigit:]]{2}\1){4}[[:xdigit:]]{2}} $Cust3 C3MacAddress
regexp -all {10\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){2}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)} $Cust3 C3IpAddress
regexp -all {(?:[[:xdigit:]]{2}([.-:]))(?:[[:xdigit:]]{2}\1){4}[[:xdigit:]]{2}} $Cust4 C4MacAddress
regexp -all {10\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){2}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)} $Cust4 C4IpAddress
return "$C1MacAddress\t$C1IpAddress\n$C2MacAddress\t$C2IpAddress\n$C3MacAddress\t$C3IpAddress\n$C4MacAddress\t$C4IpAddress"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:16:43+00:00Added an answer on June 16, 2026 at 4:16 pm

    Well, assuming that we load it from a txt file, that would be how I’d do it:

    set input [open "file.txt" r]
    set output [open "output.txt" w]
    set count 1
    
    while {[gets $input line] != -1} {
        if {$line == ""} {continue} #Skip empty lines
        regexp -all {(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})} $line - MacAddress #trap the mac address and store into $MacAddress
        regexp -all {(\d+\.\d+\.\d+\.\d+)} $line - IpAddress #trap the IP address and store into $IpAddress
        puts $output "Customer $count: $MacAddress $IpAddress"
        incr count
    }
    
    close $input
    close $output
    

    And I just thought it could be fancy if you could say which customer is which ^^. You can remove the part ‘Customer $count’ and any lines involving ‘$count’ if you don’t need that extra feature.

    Or if the input data is in table form (meaning the information you need are in the same columns, I’d go for:

    set input [open "file.txt" r]
    set output [open "output.txt" w]
    set count 1
    
    while {[gets $input line] != -1} {
        if {$line == ""} {continue} #Skip empty lines
        regsub -all { +} $line " " newline #trims excess spaces
        set MacAddress [lindex [split $line " "] 6]
        set MIpAddress [lindex [split $line " "] 8]
        puts $output "Customer $count: $MacAddress $IpAddress"
        incr count
    }
    
    close $input
    close $output
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have this list that i am working on. When i move the
hello i am working on a small uni project. nad the problem is that
Hello I have a small binary tree program in c that I'm working on
Hello there i've written a small functions that takes two lists and compares them
I'm working on a small ruby client that sends a continuous stream of information
Hello i am working about a articles script i have a small problem in
First question here so hello everyone. The requirement I'm working on is a small
Hello I'm working on a problem that requires me to change an set array
Hello all I am working in javascript and html5.I want to ask that how
I'm working on a small site that I would like to change a little

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.