Sponsored Content
Full Discussion: I.p address of machine
Top Forums Programming I.p address of machine Post 302740083 by Corona688 on Wednesday 5th of December 2012 01:30:37 PM
Old 12-05-2012
Code:
#include <stdio.h>

int main(void)
{
        char buf[512];
        int a, b, c, d;

        FILE *fp=popen("/sbin/ifconfig eth0", "r");

        if(fp == NULL) return(1);

        while(fgets(buf, 512, fp) != NULL)
        {
                if(sscanf(buf, " inet addr:%d.%d.%d.%d", &a, &b, &c, &d)==4)
                        printf("%d.%d.%d.%d\n", a, b, c, d);
        }

        pclose(fp);

        return(0);
}

These 2 Users Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Changing Machine IP address

Hopefully someone can help with this. I need the command to change the IP address on a machine (7 Replies)
Discussion started by: kkinnon
7 Replies

2. UNIX for Dummies Questions & Answers

Restricting access to a machine by IP Address

I have a need to allow only certain IP addresses to access a machine running solaris 9. I am not sure how this can be accomplished. Thanks in advance for your help. Patch (2 Replies)
Discussion started by: patch
2 Replies

3. Programming

How to get IP Address of machine?

Is there any API call to get IP Address of a machine? I know there is function which returns name of the machine, gethostname(). But I need the IP. Thanks & Regards, Ahsan (7 Replies)
Discussion started by: Ahsan
7 Replies

4. 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

5. Shell Programming and Scripting

How to get Windows machine's IP address from Unix?

I am using windows Xp. From windows I would connect to my IBM AIX unix machine using telnet client. Is there any command available to view the IP address of Windows machine from Unix? (Note that ifconfig will give unix mahcine's IP address currently logged in.) (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

6. UNIX for Advanced & Expert Users

IP address of machine

Hi i want to know the Ip address of the machine from where i logged into the unix server and made some changes to a file. Can I know the last changes made to a unix file ? (3 Replies)
Discussion started by: harneet2004us
3 Replies

7. UNIX for Dummies Questions & Answers

IP address of Unix machine

Can any one please tell me how to find the IP address of the Unix machine we are in? (9 Replies)
Discussion started by: thoothukudiking
9 Replies

8. Solaris

How to get the IP address / Host name of client machine

Hi How to get the IP address / Host name of a particular user connected to Unix Server. For example: If used 'DevUser1' is connected to Unix server. I need to find out from which PC this connection has been made. How can this be achieved? Thanks (6 Replies)
Discussion started by: MVL
6 Replies

9. UNIX for Dummies Questions & Answers

Static IP address for solaris 10 virtual machine

Hi All I am having a solaris 10 virtual machine on vista (using vmware 7) laptop. Now i want to access virtual machine from vista using putty. Problem is that i insalled the solaris machine as dhcp. and whenever i connect to internet or reboot my system the IP address of solaris... (1 Reply)
Discussion started by: ankurk
1 Replies

10. Solaris

i want to set ip address to a virtual machine

hi all i want to set ip address to a vitrual machine i am using following command. but it is not ifconfig -a command output. what is wrong i dont know bash# ifconfig interfacename plumb bash# ifconfig interfacename auto-dhcp Please use code tags next time for your code and data. (4 Replies)
Discussion started by: nikhil kasar
4 Replies
WAKE(8) 						    BSD System Manager's Manual 						   WAKE(8)

NAME
wake -- send Wake on LAN frames to hosts on a local Ethernet network SYNOPSIS
wake [interface] lladdr [lladdr ...] DESCRIPTION
The wake program is used to send Wake on LAN (WoL) frames over a local Ethernet network to one or more hosts using their link layer (hard- ware) addresses. WoL functionality is generally enabled in a machine's BIOS and can be used to power on machines from a remote system with- out having physical access to them. interface is an Ethernet interface of the local machine and is used to send the Wake on LAN frames over it. If there is only one Ethernet device available that is up and running, then the interface argument can be omitted. lladdr is the link layer address of the remote machine. This can be specified as the actual hardware address (six hexadecimal numbers separated by colons) or as a hostname entry in /etc/ethers. wake accepts multiple lladdr addresses. Link layer addresses can be determined and set using ifconfig(8). FILES
/etc/ethers Ethernet host name data base. SEE ALSO
ethers(5), ifconfig(8) AUTHORS
wake was written by Marc Balmer <marc@msys.ch>. BSD
December 27, 2009 BSD
All times are GMT -4. The time now is 10:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy