Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-19-2006, 10:21 PM
|
#1
|
|
Member
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Rep:
|
php : how to get netbios name for windows pc in a LAN?
hi all,
I want to create a web-based php program to scan a LAN to get IP, NETBIOS NAME and MAC ADDRESS. It is like nbtscan program. Anyone ?
|
|
|
|
03-19-2006, 11:53 PM
|
#2
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
Code:
system ("ipconfig/all > c:\\temp\tmp.txt");
, then open and parse "tmp.txt" for hostname, MAC address, et al?
|
|
|
|
03-20-2006, 12:49 AM
|
#3
|
|
Member
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Original Poster
Rep:
|
no. i mean how to get netbios name and other info on other computer in the same LAN.
|
|
|
|
03-20-2006, 01:10 AM
|
#4
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
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?
|
|
|
|
03-20-2006, 01:21 AM
|
#5
|
|
Senior Member
Registered: Aug 2005
Posts: 1,755
Rep:
|
Quote:
|
Originally Posted by zamri
It is like nbtscan program.
|
Well then why don't you just call nbtscan from your script?
|
|
|
|
03-20-2006, 01:27 AM
|
#6
|
|
Member
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Original Poster
Rep:
|
i mean nbtscan. for more info on nbtscan take a look here : http://www.inetcat.org/software/nbtscan.html
I want to develop a php script that can do the same as nbtscan.
err.. u know what i mean?
|
|
|
|
03-20-2006, 02:54 AM
|
#7
|
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,780
|
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," ");
}
|
|
|
|
03-20-2006, 03:39 AM
|
#8
|
|
Member
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Original Poster
Rep:
|
thanks for the tip. anyone know how to write a pure php script to function the same as nbtscan?
|
|
|
|
08-08-2006, 03:58 PM
|
#9
|
|
LQ Newbie
Registered: Aug 2006
Posts: 1
Rep:
|
Here is the deal
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:34 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|