LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-03-2008, 11:10 PM   #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-03-2008, 11:25 PM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
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-03-2008, 11:25 PM   #3
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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-03-2008, 11:32 PM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

That's why I suggested the 'man ifconfig'. Spoon feed everything and they will not learn.
 
Old 02-05-2008, 03: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 10:23 PM.
 
  


Reply



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-08-2007 11:16 PM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 07:55 AM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 10:21 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 10:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:10 PM.

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
Open Source Consulting | Domain Registration