LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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



Reply
 
Search this Thread
Old 03-19-2006, 11:21 PM   #1
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Rep: Reputation: 30
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 ?
 
Old 03-20-2006, 12:53 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Code:
system ("ipconfig/all > c:\\temp\tmp.txt");
, then open and parse "tmp.txt" for hostname, MAC address, et al?
 
Old 03-20-2006, 01:49 AM   #3
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Original Poster
Rep: Reputation: 30
no. i mean how to get netbios name and other info on other computer in the same LAN.
 
Old 03-20-2006, 02:10 AM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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?
 
Old 03-20-2006, 02:21 AM   #5
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 48
Quote:
Originally Posted by zamri
It is like nbtscan program.
Well then why don't you just call nbtscan from your script?
 
Old 03-20-2006, 02:27 AM   #6
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Original Poster
Rep: Reputation: 30
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?
 
Old 03-20-2006, 03:54 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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," ");
}
 
Old 03-20-2006, 04:39 AM   #8
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Original Poster
Rep: Reputation: 30
thanks for the tip. anyone know how to write a pure php script to function the same as nbtscan?
 
Old 08-08-2006, 04:58 PM   #9
liquidpele
LQ Newbie
 
Registered: Aug 2006
Posts: 1

Rep: Reputation: 0
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.
 
  


Reply

Tags
netbios, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
php site testing on my local LAN duffboygrim Linux - General 2 05-16-2004 03:54 AM
Netbios settins in windows 2000 elynum Linux - Networking 1 02-06-2004 11:09 PM
Netbios (cannot ping windows box using machine name) murray_linux Linux - Networking 2 02-02-2004 02:16 PM
Why does smbclient require NetBIOS name when windows doesn't? amaze Linux - General 2 08-15-2003 07:19 AM
xsmbrowser netbios networking with windows warpig Linux - Networking 2 05-23-2003 08:42 AM


All times are GMT -5. The time now is 06:39 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration