LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 03-19-2006, 11:21 PM   #1
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Thanked: 0
php : how to get netbios name for windows pc in a LAN?


[Log in to get rid of this advertisement]
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 ?
zamri is offline  
Tag This Post ,
Reply With Quote
Old 03-20-2006, 12:53 AM   #2
paulsm4
Senior Member
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 3,316
Thanked: 144
Code:
system ("ipconfig/all > c:\\temp\tmp.txt");
, then open and parse "tmp.txt" for hostname, MAC address, et al?
paulsm4 is offline     Reply With Quote
Old 03-20-2006, 01:49 AM   #3
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Thanked: 0

Original Poster
no. i mean how to get netbios name and other info on other computer in the same LAN.
zamri is offline     Reply With Quote
Old 03-20-2006, 02:10 AM   #4
paulsm4
Senior Member
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 3,316
Thanked: 144
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?
paulsm4 is offline     Reply With Quote
Old 03-20-2006, 02:21 AM   #5
spooon
Senior Member
 
Registered: Aug 2005
Location: Hell
Distribution: Fedora Core 5
Posts: 1,754
Thanked: 0
Quote:
Originally Posted by zamri
It is like nbtscan program.
Well then why don't you just call nbtscan from your script?
spooon is offline     Reply With Quote
Old 03-20-2006, 02:27 AM   #6
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Thanked: 0

Original Poster
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?
zamri is offline     Reply With Quote
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 8.04 (upgraded from 6.06), Ubuntu Netbook Remix 9.04
Posts: 2,741
Thanked: 87
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," ");
}
Wim Sturkenboom is offline     Reply With Quote
Old 03-20-2006, 04:39 AM   #8
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157
Thanked: 0

Original Poster
thanks for the tip. anyone know how to write a pure php script to function the same as nbtscan?
zamri is offline  
Tag This Post ,
Reply With Quote
Old 08-08-2006, 04:58 PM   #9
liquidpele
LQ Newbie
 
Registered: Aug 2006
Posts: 1
Thanked: 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.
liquidpele is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 04:21 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration