NetStumbler.org Forums

Go Back   NetStumbler.org Forums > NetStumbler Community > Scripts
Register Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 12-13-2005   #1 (permalink)
Mach5
Registered Member
 
Join Date: Nov 2005
Posts: 2
Python NS Scripts

Has anyone sucessfully coded a python script for netstumbler? I've made some attempts at it using the VB master script as an example, but py and vb aren't imported in the same way. I see that NS uses some python library called axscript (in the win32com lib), but there is little documentation on it. Besides hacking through code (as I'm doing now), I'm hoping someone here has an example or at least a hint . Thanks in advance!
Mach5 is offline   Reply With Quote
Old 04-10-2006   #2 (permalink)
Mach5
Registered Member
 
Join Date: Nov 2005
Posts: 2
bump! c'mon people, no one has ANY idea?
Mach5 is offline   Reply With Quote
Old 04-10-2006   #3 (permalink)
Dutch
Humourless EuroMod.
 
Dutch's Avatar
 
Join Date: Mar 2004
Location: City of Mermaids, Denmark
Posts: 6,813
Quote:
Originally Posted by Mach5
bump! c'mon people, no one has ANY idea?
NS does not have any embedded scripting engine. Any scripts executed by NS needs to have a scripting engine installed in Windows. If there's no Python scripting engine available, you are SOL.
What NS does is start the scripting engine with the script specified and expose some variables and functions that the scripting engine can call to get data.
Python AFAIK is not a scripting engine, but an interpreted programming language.

Dutch
__________________
All your answers are belong to Google. SEARCH DAMMIT!
Warning. Warning.
Low C8H10N4O2 level detected. Operator halted....
Dutch is offline   Reply With Quote
Old 10-10-2006   #4 (permalink)
quhaha
Registered Member
 
Join Date: Oct 2006
Posts: 5
ok I installed ActivePython from ActiveState. NetStumbler now let me choose a python file as external script.

My python file looks like:
Code:
PlaySound("C:\Program Files\Network Stumbler\ns-signal-1.wav")
Of course it says:
Code:
---------------------------
NetStumbler
---------------------------
An error was reported in your script.



Python ActiveX Scripting Engine

Traceback (most recent call last):
  File "<Script Block >", line 1, in ?
    PlaySound("C:\Program Files\Network Stumbler\ns-signal-1.wav")
NameError: name 'PlaySound' is not defined


Line:1 Char: 0

Exception occurred.
because i didn't import anything that defines PlaySound...
So, which library defines PlaySound??

Thanks.
quhaha is offline   Reply With Quote
Old 10-10-2006   #5 (permalink)
Thorn
Did you do the math?
 
Thorn's Avatar
 
Join Date: Apr 2002
Location: Villa Straylight
Posts: 10,002
Quote:
Originally Posted by quhaha
ok I installed ActivePython from ActiveState. NetStumbler now let me choose a python file as external script.

My python file looks like:
Code:
PlaySound("C:\Program Files\Network Stumbler\ns-signal-1.wav")
Of course it says:
Code:
---------------------------
NetStumbler
---------------------------
An error was reported in your script.



Python ActiveX Scripting Engine

Traceback (most recent call last):
  File "<Script Block >", line 1, in ?
    PlaySound("C:\Program Files\Network Stumbler\ns-signal-1.wav")
NameError: name 'PlaySound' is not defined


Line:1 Char: 0

Exception occurred.
because i didn't import anything that defines PlaySound...
So, which library defines PlaySound??

Thanks.
It's the "winsound" library.

Google "Python playsound" and "Python playsound winsound", and you should find plenty of references.
__________________
Thorn
Sex and Violence. You can't enjoy one, if you don't survive the other. (And that works both ways...)

Last edited by Thorn : 10-11-2006 at 05:41 AM.
Thorn is offline   Reply With Quote
Old 10-11-2006   #6 (permalink)
quhaha
Registered Member
 
Join Date: Oct 2006
Posts: 5
Quote:
Originally Posted by Thorn
It's the "winsound" library.

Google "Python playsound" and "Python playsound winsound", and you hsould find plenty of references.
Thanks!!!

Now, I can do stuff like:
Code:
import winsound
import easygui

easygui.msgbox('lol')
winsound.PlaySound("ns-signal-1.wav", winsound.SND_FILENAME)
easygui is from : http://ferg.org/easygui/ (simple Tkinter routines)

If I run above, it displays a message box and when I close it, it plays sound (easygui.msgbox probably has a loop).

So far so good.

Now, I want to try OnScalResult:
First, using JScript:
Code:
function OnScanResult(SSID,BSSID,CapFlags,Signal,Noise,LastSeen) {
	PlaySound("ns-signal-1.wav");
}
If I run above, it plays periodic sound, whenever scan is done.

Now, onto Python:
Code:
import winsound

def OnScanResult(SSID,BSSID,CapFlags,Signal,Noise,LastSeen):
    winsound.PlaySound("ns-signal-1.wav", winsound.SND_FILENAME)
Now, the script doesn't even run (when I click Apply, it shows Not Running).

Do I have to put OnScanResult to some specific module??

I don't know why JScript version works but not Python version...
Ok, to make Python version really identical to JScript version, I did:
Code:
import winsound
def PlaySound(name):
    winsound.PlaySound(name, winsound.SND_FILENAME)

def OnScanResult(SSID,BSSID,CapFlags,Signal,Noise,LastSeen):
    PlaySound("ns-signal-1.wav")
Still, NetStumbler doesn't seem to call OnScanResult...
Help.
Thanks.


-edit
Better yet, if there is a documentation that describes how netstumbler calls those functions..etc will be awesome!!!!!!

Last edited by quhaha : 10-11-2006 at 06:46 AM.
quhaha is offline   Reply With Quote
Old 10-11-2006   #7 (permalink)
Thorn
Did you do the math?
 
Thorn's Avatar
 
Join Date: Apr 2002
Location: Villa Straylight
Posts: 10,002
Exclamation

Quote:
Originally Posted by quhaha
Thanks!!!

...

easygui is from : http://ferg.org/easygui/ (simple Tkinter routines)
...
Help.
Thanks.
You're welcome, but I can't help anymore on this. I don't know Python; it's just my Search Fu is apparently much stronger than your's is.

I do know a lot of other languanges for both programming and scripting, and the fact that you're using a GUI while you don't seem to know or understand the underlying library structure is working against you. GUIs are great tools to speed up the develpment process if you know what you are doing. However, if you don't know or understand the underlying language itself, a GUI will just complicate the subject. Real programmers use the command line.

Maybe someone else can help, but it would seem that you really just need to read a book or three on Python, and learn to use some search tools.
__________________
Thorn
Sex and Violence. You can't enjoy one, if you don't survive the other. (And that works both ways...)
Thorn is offline   Reply With Quote
Old 10-11-2006   #8 (permalink)
quhaha
Registered Member
 
Join Date: Oct 2006
Posts: 5
GUI is not really the point... I just wanted to know how come NetStumbler calls JScript function OnResultScan..but not Python's..I think Python's OnScanResult is valid function...it runs on Python Interpreter.
quhaha is offline   Reply With Quote
Old 10-11-2006   #9 (permalink)
Dutch
Humourless EuroMod.
 
Dutch's Avatar
 
Join Date: Mar 2004
Location: City of Mermaids, Denmark
Posts: 6,813
Quote:
Originally Posted by quhaha
GUI is not really the point... I just wanted to know how come NetStumbler calls JScript function OnResultScan..but not Python's..I think Python's OnScanResult is valid function...it runs on Python Interpreter.
Netstumbler doesn't call any functions.
It's the script that calls the functions that Netstumbler exposes to the Scripting engines.
You need to read up on how to call external functions from what ever scripting language you choose to use.

See this for further information.

Dutch
__________________
All your answers are belong to Google. SEARCH DAMMIT!
Warning. Warning.
Low C8H10N4O2 level detected. Operator halted....

Last edited by Dutch : 10-11-2006 at 07:13 AM.
Dutch is offline   Reply With Quote
Old 10-11-2006   #10 (permalink)
Thorn
Did you do the math?
 
Thorn's Avatar
 
Join Date: Apr 2002
Location: Villa Straylight
Posts: 10,002
Quote:
Originally Posted by quhaha

-edit
Better yet, if there is a documentation that describes how netstumbler calls those functions..etc will be awesome!!!!!!
Yes, it's a sticky for a reason.

Official NetStumbler Scripting Guide

or http://www.stumbler.net/scripting.html

Quote:
Originally Posted by quhaha
GUI is not really the point... I just wanted to know how come NetStumbler calls JScript function OnResultScan..but not Python's..I think Python's OnScanResult is valid function...it runs on Python Interpreter.
You're missing the point about not fully understanding the lanquage. A GUI will add more things you don't understand. You need to have a basic understanding of the language before you start getting fancy with it, that's all. It's just a simple matter of learning to walk before learning to run.
__________________
Thorn
Sex and Violence. You can't enjoy one, if you don't survive the other. (And that works both ways...)
Thorn is offline   Reply With Quote
Old 10-11-2006   #11 (permalink)
quhaha
Registered Member
 
Join Date: Oct 2006
Posts: 5
maybe i need to learn COM stuff. i give up. it'll be faster to learn VB
quhaha is offline   Reply With Quote
Old 10-11-2006   #12 (permalink)
Dutch
Humourless EuroMod.
 
Dutch's Avatar
 
Join Date: Mar 2004
Location: City of Mermaids, Denmark
Posts: 6,813
Quote:
Originally Posted by quhaha
maybe i need to learn COM stuff. i give up. it'll be faster to learn VB
If you want to hang around these forums you need to learn to write like an adult. There's a reason why capital letters, punctuation and the shift key exists on your keyboard. Read the Welcome Desk section, and pay particular note to the thread regarding the usage of proper written english around here.

Dutch
__________________
All your answers are belong to Google. SEARCH DAMMIT!
Warning. Warning.
Low C8H10N4O2 level detected. Operator halted....
Dutch is offline   Reply With Quote
Old 10-11-2006   #13 (permalink)
theprez98
SpoonfeederExtraordinaire
 
theprez98's Avatar
 
Join Date: Jan 2005
Location: Maryland
Posts: 3,613
Quote:
Originally Posted by Mach5
bump! c'mon people, no one has ANY idea?
Just a small recommendation, we don't "bump" threads here.
__________________
:00475160 0E A6 AE A0 19 E3 A3 46 .......F
:00475168 0D 65 17 0C 53 70 6F 6F .e..Spoo
:00475170 6E 66 65 65 64 65 72 2E nfeeder.
:00475178 45 78 74 72 61 6F 72 64 Extraord
:00475180 69 6E 61 69 72 65 5D 3B inaire];
:00475188 8B 9E 92 5A FF 5D A6 F0 ...Z.]..
theprez98 is offline   Reply With Quote
Old 10-11-2006   #14 (permalink)
quhaha
Registered Member
 
Join Date: Oct 2006
Posts: 5
Code:
#!C:/Perl/bin/perl.exe -w

sub OnScanResult {
	my($sid,$mac,$flags,$signal,$noise,$ls) = @_;
	PlaySound('ns-signal-1.wav');
}
That one works too.
I just noticed that NetStumbler supports Python.AXScript and PerlScript, not Python and Perl.

I think win32com.axscript module isn't implemented yet (Not sure about this).
Probably that explains why PerlScript already has access to PlaySound but Python.AXScript doesn't (I used winsound.PlaySound).
quhaha is offline   Reply With Quote
Old 10-11-2006   #15 (permalink)
Dutch
Humourless EuroMod.
 
Dutch's Avatar
 
Join Date: Mar 2004
Location: City of Mermaids, Denmark
Posts: 6,813
Quote:
Originally Posted by quhaha
Code:
#!C:/Perl/bin/perl.exe -w

sub OnScanResult {
	my($sid,$mac,$flags,$signal,$noise,$ls) = @_;
	PlaySound('ns-signal-1.wav');
}
That one works too.
I just noticed that NetStumbler supports Python.AXScript and PerlScript, not Python and Perl.

I think win32com.axscript module isn't implemented yet (Not sure about this).
Probably that explains why PerlScript already has access to PlaySound but Python.AXScript doesn't (I used winsound.PlaySound).
So you are saying that the following, which I posted here way back in April 2006 : "Python AFAIK is not a scripting engine, but an interpreted programming language." is actually true ? Amazing, isn't it ?? Who would have thought that I did any kind of research before replying to a post here...



Dutch
__________________
All your answers are belong to Google. SEARCH DAMMIT!
Warning. Warning.
Low C8H10N4O2 level detected. Operator halted....
Dutch is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Google
 
Web NetStumbler.org

All times are GMT -7. The time now is 10:50 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 ©2007, Crawlability, Inc.


All messages express the views of the author and are for entertainment purposes only. Netstumbler.org cannot be held responsible for the authenticity of the content or the actions of its members. By using this site and its services, you warrant that you will not post any messages that are discriminating, obscene, hateful, threatening, or otherwise violates any laws and you release Netstumbler.org from any future claims of any kind whatsoever including, but not limited to, addiction and loss of productivity. All forum messages, private messages and any other content are properties of Netstumbler.org. Even if publicly available, personal or copyrighted information are not to be posted without the consent of the owner. Distribution of licensed and copyrighted materials in any way not endorsed by the copyright owner is strictly prohibited. You may not use this site and its resources to spam other sites or individuals or perform any action that violates any law. Items sold or bought in the For Sale forum are sold as is and no warranty or insurance of any kind is provided. Netstumbler.org cannot be held responsible for the outcome of any transactions and no warranty of any kind is provided, either express or implied. Vulgar words are not allowed in the subject lines ; they may be used in the message body in any forum. The Administrator, Super Moderators and Moderators of Netstumbler.org have the right to remove, edit, move or close any thread for any reason and to reveal your identity and other known information in the event of a complaint or legal action arising from any message posted by you.