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..
2 3528 pbmods 5,821
Recognized Expert Expert
Heya, AJD.
The hostname is available in your $_SERVER array.
You can get the MAC address on a Unix system via the `ifconfig` command (i.e., system('ifconfi g');). Be prepared to do some parsing, though.
Heya, AJD.
The hostname is available in your $_SERVER array.
You can get the MAC address on a Unix system via the `ifconfig` command (i.e., system('ifconfi g');). Be prepared to do some parsing, though.
Hey
thanks pbmod, But I am looking for some PHP script , as i need IP address, hostname and MAC address also ,
The script i used is , -
<?php
-
echo "IP Address Is : ";
-
echo $_SERVER['HTTP_X_FORWARDED_FOR']; // Show IP
-
-
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
-
-
echo " Host Name : ";
-
echo gethostbyaddr($ip);
-
$mac = returnMacAddress();
-
function returnMacAddress() {
-
-
// Get the arp executable path
-
$location = `which arp`;
-
// Execute the arp command and store the output in $arpTable
-
$arpTable = `$location`;
-
// Split the output so every line is an entry of the $arpSplitted array
-
$arpSplitted = split("\n",$arpTable);
-
// Get the remote ip address (the ip address of the client, the browser)
-
-
$remoteIp = $ip;
-
foreach ($arpSplitted as $value) {
-
// Split every arp line, this is done in case the format of the arp
-
// command output is a bit different than expected
-
$valueSplitted = split(" ",$value);
-
foreach ($valueSplitted as $spLine) {
-
if (preg_match("/$remoteIp/",$spLine)) {
-
$ipFound = true;
-
}
-
// The ip address has been found, now rescan all the string
-
// to get the mac address
-
if ($ipFound) {
-
// Rescan all the string, in case the mac address, in the string
-
// returned by arp, comes before the ip address
-
// (you know, Murphy's laws)
-
reset($valueSplitted);
-
foreach ($valueSplitted as $spLine) {
-
if (preg_match("/[0-9a-f][0-9a-f][:-]".
-
"[0-9a-f][0-9a-f][:-]".
-
"[0-9a-f][0-9a-f][:-]".
-
"[0-9a-f][0-9a-f][:-]".
-
"[0-9a-f][0-9a-f][:-]".
-
"[0-9a-f][0-9a-f]/i",$spLine)) {
-
return $spLine;
-
}
-
}
-
}
-
$ipFound = false;
-
}
-
}
-
return false;
-
}
-
-
It gives IP address and hostname correct but , does not show MAC address..
Sign in to post your reply or Sign up for a free account.
Similar topics |
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";
|
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".
|
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...
|
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
|
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
| |
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..
|
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():
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |