I have a query ,I am looking for a unix command using awk and grep that help me fetching a particular ip address and hostname from the host file.........??????
Not sure why you would need -i with an IP address, but you would need it for an alphabetic host name search.
Do you want to get them into variables?
If you are searching for a name, you will need to use the -E flag and give a variety of strings to match, such as:-
First on line (IP address); followed by a space
First on line (IP address); followed by a tab
Preceded by space; last on line
Preceded by tab; last on line
Preceded by space; followed by a space
Preceded by space; followed by a tab
Preceded by tab; followed by a space
Preceded by tab; followed by a tab
You also need to trim off any comments that might be picked up by mistake too. Consider searching for prod this /etc/hosts file:-
Remember that one IP address can have multiple host names associated with it in /etc/hosts. Try:-
use the tab character where it shows <tab> rather than use that as a literal string.
The ^ indicates start of line.
The $ indicates end of line.
The | is a logical or between each of the possible searches.
Even then, I might not have considered everything, but if you are looking for information on other servers, it's best to use a name and let the server figure it out through DNS in any case. If you need to talk to a particular application, get a CNAME set up in DNS and refer to that, so that if you move the application, you redirect the CNAME entry and your code need toy change.
I hope that this helps,
Robin
Liverpool/Blackburn
UK
i want to extract ip address from a file and using that ip address copy file to systems.
set fid
set content
close $fid
## Split into records on newlines
set records
send "records splited\n"
send $records\n
set timeout 600
set a "test\n"
send $a
foreach rec $records {
##... (1 Reply)
Hi All,
I have a file contains below contents, "interfacename/subnet: public (or) interfacename/subnet:cluster_interconnect"
"en2"/10.185.81.0:cluster_interconnect,"en5"/10.185.81.0:cluster_interconnect,"en6"/169.181.146.0:public... (6 Replies)
Hello All,
I am working on a script where I need to fetch the value from a log file and log file creates with different name but few thing are common
DEV_INFOMGT161_MULTI_PTC_BLD01.Stage_All_to_stp2perf1.042312114644.log
STP_12_02_01_00_RC01.Stage_stp-domain_to_stp2perf2.042312041739.log
... (2 Replies)
Hi all,
I'd like to disable sendmail permanently on my "new" 220R with freshly installed SunOS 5.10 because it prints annoying messages to the system console.
Also I'm interested in how to fix the actual problem with unqualified host name.
My unqualified host name (hostname) unknown; sleeping... (2 Replies)
All,
Iam new to unix and i have 1 requirement, can anyone help me please
I have provided the file below, i will be having similar files in 100+clients systems. i want to check the the ip address "192.168.208.40" and if it is present then i should get a mail alert, if the ip address is not... (1 Reply)
Hi All,
So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says:
It should say:
What gives? And how do... (4 Replies)
Hi guys,
Please help me out in this problem. I have two files
FILE1
abc-23 : 4529675
cde-42 : 9824532
dge-91 : 1245367
gre-45 : 9824532
fgr-76 : 4529675
FILE2
4529675 : Gal Glu house-2-be
9824532 : cat mouse
1245367 : sirf surf-2-beta
where FILE2 is a static file with fixed... (5 Replies)
Hi All,
Requirement is to fetch hostname and instance name using shell script from all configuration files on a server R12 on IBM AIX...
could anyone please share such an experience encountered before.Is there such a script available in this forum or any other site..
Thanks for your time!... (0 Replies)
Hello,
I am new to Solaris.
I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)