473,796 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fetching Host name and MAC address..

123 New Member
Hey all,
I am trying to make one script which I can run on different computers and give me the hostname as well as the MAC address.

Can you please help me how to do so ??script in Perl or PHP will work...
Thanks..
Jun 26 '08 #1
3 6825
eWish
971 Recognized Expert Contributor
Writing the code is going to be up to you. If you have problems we will be glad to help.

Check CPAN for Net::Domain and Net::Mac

Perlfaq9

--Kevin
Jun 26 '08 #2
ajd335
123 New Member
Writing the code is going to be up to you. If you have problems we will be glad to help.

Check CPAN for Net::Domain and Net::Mac

Perlfaq9

--Kevin
Hi Kevin,
I have written some code , which gives me IP address as well as Host name , but not the MAC address.I am not sure , how can i Get the MAC address of particular IP address using PHP..
My code is ,
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. <?php
  3. echo "IP Address Is : ";
  4. echo $_SERVER['HTTP_X_FORWARDED_FOR']; // Show IP
  5.  
  6. $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  7.  
  8. echo " Host Name : ";
  9. echo gethostbyaddr($ip);
  10. $mac = returnMacAddress();
  11. function returnMacAddress() {
  12.  
  13. // Get the arp executable path
  14. $location = `which arp`;
  15. // Execute the arp command and store the output in $arpTable
  16. $arpTable = `$location`;
  17. // Split the output so every line is an entry of the $arpSplitted array
  18. $arpSplitted = split("\n",$arpTable);
  19. // Get the remote ip address (the ip address of the client, the browser)
  20.  
  21. $remoteIp = $ip;
  22. foreach ($arpSplitted as $value) {
  23. // Split every arp line, this is done in case the format of the arp
  24. // command output is a bit different than expected
  25. $valueSplitted = split(" ",$value);
  26. foreach ($valueSplitted as $spLine) {
  27. if (preg_match("/$remoteIp/",$spLine)) {
  28. $ipFound = true;
  29. }
  30. // The ip address has been found, now rescan all the string
  31. // to get the mac address
  32. if ($ipFound) {
  33. // Rescan all the string, in case the mac address, in the string
  34. // returned by arp, comes before the ip address
  35. // (you know, Murphy's laws)
  36. reset($valueSplitted);
  37. foreach ($valueSplitted as $spLine) {
  38. if (preg_match("/[0-9a-f][0-9a-f][:-]".
  39. "[0-9a-f][0-9a-f][:-]".
  40. "[0-9a-f][0-9a-f][:-]".
  41. "[0-9a-f][0-9a-f][:-]".
  42. "[0-9a-f][0-9a-f][:-]".
  43. "[0-9a-f][0-9a-f]/i",$spLine)) {
  44. return $spLine;
  45. }
  46. }
  47. }
  48. $ipFound = false;
  49. }
  50. }
  51. return false;
  52. }
  53.  
  54.  
Jun 26 '08 #3
eWish
971 Recognized Expert Contributor
I don't know any PHP and if you prefer PHP I can move your post to the PHP forum. If you want to use perl the checkout the links I provided and then it should be a piece of cake.

--Kevin
Jun 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2062
by: Andres Baravalle | last post by:
Hi, I have a problem using a URL fetching algorithm (HTTP 1.0). To download an image, I used to use this algorithm: <?php Header("Content-type: image/gif"); $referer = "http://www.creators.com/comics_show.cfm?comicname=mrh";
9
3348
by: Jeff | last post by:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For example if I type HostName.domain.com in my browser I want to return it exactly as it appears in the location part of the browser "HostName.domain.com" but it keeps returning a case insensitive result "hostname.domain.com".
0
1916
by: C3 | last post by:
Hi everone. I'm trying to write a shell script that fetches a number of images from a map website (www.whereis.com.au). Basically, the page asks you for a street address and then queries the server in a strange way, and then displays the map you asked for. It then allows you to scroll in different directions from that map. My aim is to be able to write a program that will take a street address, query the website, and return the...
5
8187
by: Patrick | last post by:
Hi all, In my SQL procedures in DB2 8.2, I current declare several cursors that return select statements with 10 columns in it. As a result, assigning host variables becomes a coding mess, as I would have to declare anywhere from 50-100 host variables just so I can process them. Is it possible to fetch the row from a cursor into a single
2
4765
by: martin lanny | last post by:
Simple network scanner is a part of my dotnet solution. It pings ip addresses in a selected network range and gives me the response time for each computer it finds. Anyhow, I would need to retrieve two more pieces of information for each active (local network) IP address: - Computer's Host Name - Mac Address
2
3528
by: ajd335 | last post by:
Hey all, I am trying to make one script which I can run on different computers and give me the hostname as well as the MAC address. Can you please help me how to do so ??script in Perl or PHP will work... Thanks..
1
1233
by: Ivan Ven Osdel | last post by:
>----- Original Message ----- Here's a function I wrote for checking remote or local file existence. It works for me but admittedly I haven't tested many cases with it. Also its currently specific to an http URI scheme. def fileExists(self, fileUrlPath): fileExists = False if "http:" in fileUrlPath.lower():
4
4283
by: tokcy | last post by:
HI every one, i am using tooltip on click of link and i want like when that tooltip open then background window would be blure(). can anyone help me...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.