Sponsored Content
Full Discussion: retrieve IP of local machine
Top Forums Programming retrieve IP of local machine Post 96679 by matrixmadhan on Monday 23rd of January 2006 12:11:15 AM
Old 01-23-2006
try this,

Code:
# include<netdb.h>
# include<stdio.h>
# include<netinet/in.h>
# include<arpa/inet.h>
# include<sys/socket.h>

int main(int argc, char *argv[])
{
long conv;
struct hostent *h;
if(argc != 2)
{
fprintf(stderr, "USAGE: <binary> <IP_ADDRESS>\n");
exit(1);
}
if( (int) (conv=inet_addr(argv[1])) == -1 )
{
fprintf(stderr, "IP Notation Wrong\n");
exit(1);
}
h=gethostbyaddr((char*)&conv, sizeof(conv), AF_INET);
if(h == (struct hostent *) NULL)
{
fprintf(stderr, "Resolve failed for %s\n", argv[1]);
exit(1);
}
fprintf(stderr, "Name: %s\n", h->h_name);
return 0;
}

 

10 More Discussions You Might Find Interesting

1. IP Networking

how to retrieve IP address of a machine

hi is there is any command that retrieves the IP address of a machine. Also is there any function in c that does the same. thankx (5 Replies)
Discussion started by: mridula
5 Replies

2. IP Networking

Workgroup of local machine

Hi Guys, How to find the Workgroup/Domain name of my local machine in unix? Please suggest some link. Thanks. sunil. (3 Replies)
Discussion started by: skumar2011
3 Replies

3. Red Hat

To find the LATEST file from a dir on REMOTE machine and SCP to local machine?

Hi All, URGENT - Please help me form a scipt for this: I need the LATEST file from a dir on REMOTE machine to be SCP'd to a dir on local machine. (and I need to execute this from local server) I know that the below cmd is used to find the LATEST file from a dir. But this command is not... (3 Replies)
Discussion started by: me_ub
3 Replies

4. Shell Programming and Scripting

Retrieve all DNS zones (domains) from local server

Hello, I am trying to retrieve all DNS zones from the local bind server without parsing the /var/named folder, removing .db from the zone file names and the special zones files. I am looking for some kind of named, dig etc command that would retrieve all domains from the server eventually with... (2 Replies)
Discussion started by: AndyB78
2 Replies

5. Shell Programming and Scripting

How to transfer files from unix machine to local machine using shell script?

Hi All.. Am new to Unix!! Am creating a shell script in which a scenario is like i have transfer the output file from unix machine (Server) to local directory (Windows xp). And also i have to transfer the input file from the local directory to Unix machine (Server) Any help from you... (1 Reply)
Discussion started by: vidhyaS
1 Replies

6. UNIX for Dummies Questions & Answers

Retrieve data from Remote machine

Hello Please I ask if it is possible to recover data that is stored on a remote machine that I access via ssh on a usb ? if so, how? Thank you so much (5 Replies)
Discussion started by: chercheur857
5 Replies

7. UNIX for Advanced & Expert Users

FTP While transfering files to local machine to remote machine

Hi Am using unix Ksh Am getting the problem while transferring zero size files through the script . When i transfer zero size files from local machine to remote machine manually i can able to do it . My question its beause of zero size files am not able to transfer through script ? or its... (2 Replies)
Discussion started by: Venkatesh1
2 Replies

8. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

9. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

10. Shell Programming and Scripting

Help with fetching the data from remote machine from my jumpbox(local machine)

Team, Presently i am running a script from my local box(i.e jumpbox) to all the remote machines.Basically fetching basic queries like pwd,mkdir,touch etc and i am able to successfully fetch it from my local machine.But when i want to check certain database related queries like the dbstat... (20 Replies)
Discussion started by: whizkidash
20 Replies
SYSTEMD-MACHINE-ID-COMMIT.SERVICE(8)			 systemd-machine-id-commit.service		      SYSTEMD-MACHINE-ID-COMMIT.SERVICE(8)

NAME
systemd-machine-id-commit.service - Commit a transient machine ID to disk SYNOPSIS
systemd-machine-id-commit.service DESCRIPTION
systemd-machine-id-commit.service is an early boot service responsible for committing transient /etc/machine-id files to a writable disk file system. See machine-id(5) for more information about machine IDs. This service is started after local-fs.target in case /etc/machine-id is a mount point of its own (usually from a memory file system such as "tmpfs") and /etc is writable. The service will invoke systemd-machine-id-setup --commit, which writes the current transient machine ID to disk and unmount the /etc/machine-id file in a race-free manner to ensure that file is always valid and accessible for other processes. See systemd-machine-id-setup(1) for details. The main use case of this service are systems where /etc/machine-id is read-only and initially not initialized. In this case, the system manager will generate a transient machine ID file on a memory file system, and mount it over /etc/machine-id, during the early boot phase. This service is then invoked in a later boot phase, as soon as /etc has been remounted writable and the ID may thus be committed to disk to make it permanent. SEE ALSO
systemd(1), systemd-machine-id-setup(1), machine-id(5), systemd-firstboot(1) systemd 237 SYSTEMD-MACHINE-ID-COMMIT.SERVICE(8)
All times are GMT -4. The time now is 06:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy