LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2008, 12:10 AM   #1
jayakrishna
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
Post How to get MAC address


Hai all,
i have a doubt, how to get the MAC and IP address of a system. Is any system call to get the MAC and IP address.
 
Old 02-04-2008, 12:25 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Quote:
Originally Posted by jayakrishna View Post
Hai all,
i have a doubt, how to get the MAC and IP address of a system. Is any system call to get the MAC and IP address.
If you want the device information then; 'ifconfig -a' from the 'cli'.

'man ifconfig'
 
Old 02-04-2008, 12:25 AM   #3
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
The command "ifconfig" will return both the MAC and IP of all active interfaces on the system. If you want the information for just one interface, simply pass the interface name to ifconfig like "ifconfig eth0".
 
Old 02-04-2008, 12:32 AM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

That's why I suggested the 'man ifconfig'. Spoon feed everything and they will not learn.
 
Old 02-05-2008, 04:38 AM   #5
jayakrishna
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Original Poster
Rep: Reputation: 0
hai all,

i am using dup2 system call for redirecting the standard output to a file.
some text was redirected to file. then i closed the file. again i was printing some text on stdout, but it is writing to the file, but i want to print on stdout device, how can i write the program?

this is the program i had written:

int main()
{
int fd;
char buff[80];

fd = open("temp.txt", O_CREAT|O_RDWR|O_TRUNC, 0666);

dup2(fd, 1);

fgets(buff, 80, stdin);
printf("%s\n", buff);
close(fd);

printf("I am printing the text on stdout\n");

return 0;
}

Last edited by jayakrishna; 02-17-2008 at 11:23 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Single DHCP server ,to provide the ip address to a MAC address in two different subne alix123 Linux - Software 5 05-09-2007 12:16 AM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 08:55 AM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 11:21 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 05:33 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 11:33 AM


All times are GMT -5. The time now is 04:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration