Hi there, I have a script which loops through the physical interfaces of a box and populates a variable called $NIC with the interface name
so if for example $NIC is equal to "e1000g0", I am trying to figure out some awk that will get the IP for that interface from ifconfig output
Ive been trying to set up an awk statement that sets a variable called X to "1" when it find the interface in question (in this case e1000g0) and then start searching for the line containing the string "inet", then print £2 and set X=0 again so that it wont print any more
Apologies for my inexperience with awk, but does am i close with the following syntax ? please feel free to shoot me down :-) ive been trying all sorts of variatiosn but i cant get it to work
correct.
because in your previous statement NIC contains actually nothing. ( it is not replaced by e1000g0 what you were expecting )
if you really dont want to hardcode the value then use -v command line option as i suggested earlier.
instead
this should work
Thanks for your help on this, I have tried
unfortunately returns no output
again returns to the next line with no output .... i think i am missing something here
---------- Post updated at 09:39 AM ---------- Previous update was at 08:44 AM ----------
Quote:
Originally Posted by Franklin52
Or:
Franklin, if i replace the awk with a nawk this works perfectly (thankyou). if i use awk, i get syntax errors
although i dont quite understand how your statement works as im more used to the learning the if/then awk constructs, i will use it because i cant get the ones that seem logical to me to work
although i dont quite understand how your statement works as im more used to the learning the if/then awk constructs, i will use it because i cant get the ones that seem logical to me to work
thankyou very much all
Explanation:
In contrast with the next statement getline reads the next line and continues with the next statement
Hi Experts,
I am trying to get system output to capture inside awk , but not working:
Please advise if this is possible :
I am trying something like this but not working, the output is coming wrong:
echo "" | awk '{d=system ("date") ; print "Current date is:" , d }'
Thanks, (5 Replies)
I have a script problem that I am not able to solve due my very limited understanding of unix/awk.
This is the contents of test.sh
awk '{print $1}'
From the prompt if I enter:
./test.sh Hello World
I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
why the ifconfig command is not working in my machine?
it says "-bash: ifconfig: command not found"
why its says that?
actually i m looking for "how can I know the Network Interface Card physical address?"
Requesting u all for help.
thanks (3 Replies)
On prior versions to solaris 10 when I want to add/change the IP address of an interface I will use this command.
ifconfig eri0 down
ifconfig eri0 192.xxx.xxx.xxx netmask 255.xxx.xxx.xxx up
then change /etc/hosts so that /etc/hostname.eri0 picks up on the correct IP.
I strange thing... (2 Replies)
if i have the command ifconfig eth0, what will the output be and how can i use either awk or grep to isolate and display the IP address, subnet mask and physical address of my host (1 Reply)
I am trying to change an IP address on a machine running HPUX10
After I change it I can ping it from the outside but it completely locks the console. After a reboot it returns back to its previous IP. Any ideas??
Thanks
Brian (7 Replies)
This will most likely be a real dumb question for a HP-UX admin, but here it goes anyhow.
lan0 - is up and configured
lan1 - is down, I want to bring it up.
lanconfig....ifconfig is there a difference?
My real question is, in solaris there is an /etc/hostname."?" file, is there a... (4 Replies)
SunOS Release 5.7.
Original ifconfig -a output:
pnt0: flags=863<UP, BROADCAST,NOTRAILERS........
inet 10.2.34.49 netmask fffffe00 broadcast 10.2.34.255 ...
Attempted to change ip address for pnt0. Typed the following command and forgot the "netmask"
"ifconfig pnt0 10.2.35.49... (1 Reply)
I asked a similar question earlier and got a very good answer but a new doubt came up. This is a few lines of a '/sbin/ifconfig' command on my PC:
RX packets:3781025 errors:0 dropped:0 overruns:0 frame:0
TX packets:1941909 errors:0 dropped:0 overruns:0 carrier:0
Does the RX and TX packets... (1 Reply)