Sponsored Content
Full Discussion: getent hosts
Top Forums Shell Programming and Scripting getent hosts Post 302711245 by snoman1 on Friday 5th of October 2012 03:28:22 PM
Old 10-05-2012
getent hosts

korn shell script on Solaris

getent hosts <hostname> returns
IP FQDN

But I just want the output to be like this
<hostname> IP

things I have tried so far
Code:
getent hosts <hostname> |awk '{print $2,$1}'

using awk and substr
Code:
getent hosts <hostname> |nawk '{print substr($2,1,5)}'

using cut command
Code:
getent hosts <hostname> |cut -f2,1

any ideas?
I am planning on just 2 seperate commands to get my output but I want to see if I can do this using the getent hosts command
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

/etc/hosts

hello dear all , i use both sun solaries 7 and linux red hat 6.1 and i added my pc IP address in /etc/hosts . How do i refresh this file in order to make my new ip active ?? without restart . Thanks all (2 Replies)
Discussion started by: tamemi
2 Replies

2. UNIX for Dummies Questions & Answers

hosts.allow & hosts.deny

Hi! Im trying to use host.allow & host.deny to resrtic access to my sun machine, but it doesnt seem to work... I want to allow full access from certain IPīs (ssh,http,ftp,etc...) but deny all kind of conections from outsideworld, the way that im doing that is: hosts.allow ALL:127.0.0.1... (2 Replies)
Discussion started by: Sorrento
2 Replies

3. Cybersecurity

etc/hosts

I was wondering where in UNIX is file where I can delete hosts that can or ca not access UNIX machine thanks in advance (1 Reply)
Discussion started by: amon
1 Replies

4. IP Networking

etc/hosts or something else??

I was wondering where in UNIX is file where I can delete hosts that can or ca not access UNIX machine thanks in advance (5 Replies)
Discussion started by: amon
5 Replies

5. UNIX for Dummies Questions & Answers

Hosts.allow and hosts.deny

Hello everyone, This is my first posts and I did search for a questions but did not find a question that answered my question unless of course I overlooked it. I'm running Solaris 8. I use ssh for the users but I have a user called "chatterbox" that uses telnet but I need for chatterbox to... (1 Reply)
Discussion started by: huddlestonsnk
1 Replies

6. UNIX for Dummies Questions & Answers

/etc/hosts

Hello, where can I get complete specification for /etc/hosts? I found a lot of snippets but nothing where the format of file is completely written (I'm especially interested in comments in /etc/hosts) Thank you for help! (3 Replies)
Discussion started by: MartyIX
3 Replies

7. Solaris

getent not working, solaris 10 only

Hello, thanks in advance for any help! We use LDAP for our unix boxes When I run getent passwd on solaris 10, it only returns some of the ldap entries, not all. Aprox 300 of 4000. When i run the same command on linux or solaris 9, it comes back correct. my nsswitch file is good. I ran a... (6 Replies)
Discussion started by: BG_JrAdmin
6 Replies

8. AIX

aix tcp wrappers hosts.allow hosts.deny?

hi all just installed the netsec.options.tcpwrapper from expansion pack, which used to be a rpm, for my aix 6.1 test box. it is so unpredictable. i set up the hosts.deny as suggested for all and allow the sshd for specific ip addresses/hostnames. the tcpdchk says the hosts allowed and... (0 Replies)
Discussion started by: wf201626
0 Replies

9. UNIX for Dummies Questions & Answers

Where does id / getent query ?

I'm typing "id <user's id>" and its returning a different UID that what is defined in our administration system. Where does id / getent query and where is it configured to query? I'm guessing it queries the local /etc/passwd file first, and then if it doesn't find anything it would query LDAP... (2 Replies)
Discussion started by: MaindotC
2 Replies

10. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies
GETENT(1)						    BSD General Commands Manual 						 GETENT(1)

NAME
getent -- get entries from administrative database SYNOPSIS
getent database [key ...] DESCRIPTION
The getent utility retrieves and displays entries from the administrative database specified by database, using the lookup order specified in nsswitch.conf(5). The display format for a given database is as per the ``traditional'' file format for that database. The database argument may be one of: Database Display format ethers address name group group:passwd:gid:[member[,member]...] hosts address name [alias ...] networks name network [alias ...] passwd user:passwd:uid:gid:gecos:home_dir:shell protocols name protocol [alias ...] rpc name number [alias ...] services name port/protocol [alias ...] shells /path/to/shell utmpx [time] type: properties If one or more key arguments are provided, they will be looked up in database using the appropriate function. For example, ``passwd'' sup- ports a numeric UID or user name; ``hosts'' supports an IPv4 address, IPv6 address, or host name; and ``services'' supports a service name, service name/protocol name, numeric port, or numeric port/protocol name. If no key is provided and database supports enumeration, all entries for database will be retrieved using the appropriate enumeration func- tion and printed. EXIT STATUS
The getent utility exits 0 on success, 1 if there was an error in the command syntax, 2 if one of the specified key names was not found in database, or 3 if there is no support for enumeration on database. SEE ALSO
getutxent(3), ethers(5), group(5), hosts(5), networks(5), nsswitch.conf(5), passwd(5), protocols(5), rpc(5), services(5), shells(5) HISTORY
A getent command appeared in NetBSD 3.0, and was imported into FreeBSD 7.0. It was based on the command of the same name in Solaris and Linux. BSD
August 24, 2005 BSD
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy