php : how to get netbios name for windows pc in a LAN?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you mean "a PHP script on the web server scan the client PC": you can't. Thank God!
If you mean "a PHP script that gets local information about the local PC, and that PC happens to be running Windows", then "ipconfig", "hostname" (for Windows 2000 and above) and "nbtstat" are the tools you're looking for.
And of course there's always the C API "gethostbyname()"...
Our of curiousity, what are you going to be using this PHP script for?
From that page you can download the sources and compile it for your platform.
Next you can run it from within php using exec (as said by spooon).
I found the following code snippet on the net for nbtstat (it finds a username). It might help as a guideline
Code:
$ipaddress = $_SERVER["REMOTE_ADDR"];
$nbtstat = "nbtstat -A ". $ipaddress;
exec ($nbtstat,$result);
foreach ($result as $row) {
if (strpos($row,"<03>")) $username = strtok($row," ");
}
Although it is technically possible to hack up a php script to connect to remote servers and parse information provided by those servers, php does not have any way to connect to network drivers for tasks beyond that. This means you CAN'T get information about hosts on a network using PHP without PHP just calling another program or server to do it and return the information. Trying to write a pure php program for this is like trying to build a car out of rubberbands.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.