[NTLUG:Discuss] Is there an easy way?
Leroy Tennison
leroy_tennison at prodigy.net
Mon Jul 27 23:15:20 CDT 2009
Michael Barnes wrote:
> On Sun, Jul 26, 2009 at 7:00 AM, David Simmons <dave at dgnal.net> wrote:
>
>> Leroy - I would disagree that this isn't a 'scripting issue'....this is
>> EXACTLY what is Un*x's strength?! I wish I was a scripting guy, but I
>> don't
>> see why you couldn't do a increment through the phone numbers and a few
>> greps to easily spit out your answer?
>>
>> I look forward to seeing the various answers from others
>>
>> -dave
>>
>> On Sun, Jul 26, 2009 at 12:06 AM, Leroy Tennison <
>> leroy_tennison at prodigy.net
>>> wrote:
>>> I'm not even sure how to Google for this one without having to wade
>>> through too many extraneous hits so I'm posting here. I have three
>>> files and need to merge fields from each of them into a single file. A
>>> brief description of each is:
>>>
>>> File 1 has a phone number and an associated IP address (VOIP, Avaya PBX)
>>> File 2 has an IP address and an associated MAC address (Cisco router).
>>> File 3 has a MAC address and associated Cisco switch port assignment.
>>>
>>> I need a file containing phone number and associated switch port.
>>>
>>> This may be somewhat OT except I'm hoping there's a Linux utility which
>>> will meet the need. I know that I can turn each file into a database
>>> table and do some operation on two tables to "merge" their fields and
>>> then repeat again to get what I need but that's the extent of my
>>> understanding of that option. Wondering if there's a utility to take
>>> the files directly and do the "merge". This is a situation where
>>> scripting seems to be the wrong solution, I've written something similar
>>> in awk and don't want to do that again. I'm also not looking forward to
>>> writing a program in a "real programming language" to accomplish this
>>> either. Thanks for any input.
>>>
>>> _
>
>
> Part of it depends on the format of the original files. Are they text
> files with lists? Is each record on a single line? Any delineation, like
> tabs, commas, etc? Is the information in the same place on each line? If
> so, then you're in good shape. If not, it takes a little more work.
>
> You could try importing them into a spreadsheet like ooocalc. Each file in
> a separate sheet. Then sort them as necessary and merge the sheets.
>
> I would probably whip up a perl script that would go through the first file
> and get the phone and IP into variables, then go through the next file and
> get the MAC for the same IP variable. Finally go through the third file and
> find the port that matches the MAC variable, then stick the phone and port
> numbers into a file. With a foreach loop it will go through each phone
> number in the first file and you'll end up with a corresponding port in a
> new file. There are probably more elegant ways to do it, but I'm not
> particularly an elegant guy.
>
> Maybe the bigger question is this a one time deal or something that has to
> be done periodically or a list that has to remain current. If it is a
> recurring issue, especially you you need the data frequently and needs to be
> up-to-date, I would put it into a MySQL database and set up appropriate
> queries.
>
> My $.0002
>
> Michael
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>
The format of the files is predictable. May need to look into merging
sheets in oocalc, hadn't heard of that before. This is one of those
"not necessarily one time but probably not frequent" type of situations
which is why I'm trying to avoid the full sql solution (particularly
since I don't have an sql database manager set up already). Thanks for
the ideas.
More information about the Discuss
mailing list