LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2010, 11:50 AM   #61
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194

Just to confirm ... you made this change - -F"[ ]*:[ ]*" - in code for ipbits?

Except for the fact that I don't have whatmask (so using output you gave me read from a file), this is what I am using and get:

192.168.0.0/18

Last edited by grail; 05-12-2010 at 11:51 AM.
 
Old 05-12-2010, 01:00 PM   #62
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Hi grail, 1st) like to thank you very much for your help. 2nd) yes i did made the change.
if it helps you can download the whatmask program here:

http://www.laffeycomputer.com/whatmask.html

i will continue working on code you gave me since it is working for you. Maybe i am doing something wrong.
 
Old 05-12-2010, 02:35 PM   #63
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
tried several times getting the same result...!!!
 
Old 05-12-2010, 03:22 PM   #64
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
still scratching my head!!! from my end i am getting :
192.168.23.65 /20 (with the last code) !!!
tried different ways but still NO GO!!!
 
Old 05-12-2010, 04:28 PM   #65
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
maybe the extra space 192.168.23.65 /20 coming from "awk" ??!!
 
Old 05-12-2010, 06:53 PM   #66
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Yes the awk "was" outputting the space prior to /20, but the new code removes it.
Just thought I would confirm, again, that we are on the same page with the following line as i have tried it several times and it does work.
(I would also mention that copy & paste from the forum does sometimes not include all spaces!!)

Code:
ipbits=$(ifconfig eth0 | awk -F: 'NR==2{print | "whatmask "$NF}' | awk -F"[ ]*:[ ]*" '/CIDR/{print $2}')
#                ^    ^ ^   ^   ^            ^ ^         ^      ^ ^   ^    ^    ^   ^             ^
All ^ refer to spaces. i jknow some are obvious but thought I would list all to be clear
 
Old 05-12-2010, 09:54 PM   #67
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Thanks grail for your great reply. taking the time & pointing the spaces, I appreciate very much- SMART.
I will try in the lab & let you know in the morning. from what i see when i copy & paste the spaces between the [ ]do not carry over.
I will confirm it tomorrow. Once again, BIG thanks for the good job & helping me.
 
Old 05-13-2010, 07:22 AM   #68
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Hi grail,

it is working now. so it was the spaces between [ ]. Now i am working on the rest of the project to get it to the destination!!
Thank you for your help.
 
Old 05-13-2010, 07:52 AM   #69
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
No Prob ... glad you are on your way
 
Old 05-13-2010, 07:59 AM   #70
915086731
Member
 
Registered: Apr 2010
Posts: 144
Blog Entries: 6

Rep: Reputation: 2
The content of A is:
hostname 192.168.23.65
hostname 10.18.13.253
hostname 10.18.16.253
hostname 177.23.56.58

run the following command:
cat A | awk -F " " '{print $2 > NR}'

If contains 4 lines, the command creates 4 files : 1 2 3 4
file named 1 contains the first filtered line.
 
Old 05-13-2010, 08:26 AM   #71
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
I forsee a problem with this logic, have a look at new fileA submitted by OP with comments in it. NR then starts at 4 and 7 gets missed due to repeated IP.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GPG - encode file while manipulating output file name itmozart Linux - Newbie 2 10-03-2009 12:28 PM
Output Redirection - Trying to output to screen and file? helptonewbie Linux - Newbie 7 03-19-2009 07:05 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
why when redirecting output to a file any file extension seems to be fine? dr_zayus69 Linux - General 1 05-21-2005 04:09 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 07:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration