| View previous topic :: View next topic |
| Author |
Message |
kc7aad Contributor

Joined: 09 Oct 2005 Posts: 53 Location: Spokane Washington
|
Posted: Thu Dec 22, 2005 5:21 pm Post subject: Searching Multiple lines of text for different tests |
|
|
Hi All!! First of all.. Mery Christmas (If I can say that and not get shot!!)!!!
I am trying to get a set fo numbers out of a text file I have a script output'd to. Here is a small snip of the text file that is created...
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Wi-Fi Signal Strength Monitor
Version 1.0
BSSID, SSID and RSSI monitor for XP machine's Only.
SOMEONE'S NAME
03/04/05
Using Cisco Systems 350 Series PCMCIA Wireless LAN Adapter - Packet Scheduler Miniport
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -46dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -40dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -40dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -40dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -37dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -39dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -45dB
BSSID: 00:14:BF:07:4D:BD SSID: KC7AAD RSSI: -44dB
The numbers I am trying to get is after the RSSI:.. the Signal level.
I am trying to get it into a Level Control, to have a nice way as i am driving around looking at my wireless systems, to be able to see a graphical view of how well it is or is not doing.
The other option, is that this program I have, uses the NDIS Driver, to get all of this data. Is there a way to get VDS to get this data directly??
And if so, how??
Any ideas??? I am using VDS5, and have not been doing much programming (In ANY programming language), until very recently!! Trying to learn this great program, still!!
Thanks in advance!!
Rod |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Fri Dec 23, 2005 12:55 am Post subject: |
|
|
ummh ... extracting the numbers from the text file is easy enough to do ... the problem is how often is the data in the file updated and is the new entry added at the start or at the end of the file?
there are several ways of extracting the numbers and which one you use is up to you and depends on whether each line is always the same length which it looks like it is
| Code: |
%%data_file = filename and path goes here
list create, 1
list loadfile, 1, %%data_file
rem assuming first line is latest entry and assuming the data file is never empty
list seek, 1, 0
%%dummy = @item(1)
%%data = @substr(@item(1),46,47)
|
the variable %%DATA now has your number which you will need to manipulate to have it displayed on the level element which only goes up to 100 ... if your db levels never go beyond 100, then the following should work
| Code: | | dialog set, level1, %%data |
if your db levels go over 100, then you will need to manipulate %%data so that it is always less than 100
hope this helps
serge _________________
|
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1566
|
Posted: Fri Dec 23, 2005 4:01 am Post subject: |
|
|
Sounds like the perfect candidate for the PARSE command. Since your data looks uniform, you can use parse to pull the data out you want.
Borrowing from Serges code:
| Code: |
%%data_file = filename and path goes here
list create, 1
list loadfile, 1, %%data_file
rem assuming first line is latest entry and assuming the data file is never empty
list seek, 1, 0
rem change the field separator to : to parse the field contents based on that separator
rem then set the appropriate field to the variable %%data
option fieldsep,":"
parse ";;;;;;;;%%data",@item(1)
warn Signal Level: @trim(%%data)
|
|
|
| Back to top |
|
 |
kc7aad Contributor

Joined: 09 Oct 2005 Posts: 53 Location: Spokane Washington
|
Posted: Thu Dec 29, 2005 1:48 am Post subject: |
|
|
Thanks guys!! I will give this a try and let you know!!
BTW: Anybody know how to get data from an NDIS Driver??? HMMMMM!! |
|
| Back to top |
|
 |
kc7aad Contributor

Joined: 09 Oct 2005 Posts: 53 Location: Spokane Washington
|
Posted: Thu Dec 29, 2005 6:04 am Post subject: |
|
|
Also.. The data is updated about every 1 second. Needs to be as much real time as it can be so it is fairly acurite!!
Doing signal reading for a WiFi Network for work, so need to be able to track it as I have it deployed, so I can depict acurite coverage maps!!
Thus the reason for the questions about NDIS Drivers!
Thanks again!! |
|
| Back to top |
|
 |
kc7aad Contributor

Joined: 09 Oct 2005 Posts: 53 Location: Spokane Washington
|
Posted: Thu Dec 29, 2005 6:34 am Post subject: |
|
|
OK.. So tried both ways and nothing.. Here is the code so far. Keep in mind.. AMATEUR AT PROGRAMMING!!!!
| Code: | Title Signal Strength Meter
DIALOG CREATE,802.11a/b/g WiFi Signal Strength,-1,0,300,415,NOSYS
REM *** Modified by Dialog Designer on 12/21/2005 - 16:48 ***
DIALOG ADD,BUTTON,SIGNAL,15,15,100,100,Start,Start Signal Aquisition,HAND
DIALOG ADD,BUTTON,EXIT,15,185,100,100,Exit,Close Program,HAND
DIALOG ADD,LEVEL,RSSI,125,15,99,253,0
DIALOG ADD,STATUS,%P,%P
DIALOG ADD,TIME,TIME,355,150,100,30
DIALOG SHOW
:Evloop
wait event
goto @event()
:TIMER
:SIGNALBUTTON
# RUNH c:\script1.bat,1
%%data_file = C:\TEST.TXT
list create,1
list loadfile,1,%%data_file
rem assuming first line is latest entry and assuming the data file is never empty
list seek,1,0
rem change the field separator to : to parse the field contents based on that separator
rem then set the appropriate field to the variable %%data
option fieldsep,":"
parse ";;;;;;;;%%data",@item(1)
info Signal Level: @trim(%%data)
#%P = @PIPE()
#info %P
goto level11
goto evloop
:LEVEL11
dialog set,rssi,%%data
END
REPEAT 20
goto evloop
:EXITBUTTON
goto CLOSE
:Close
exit
|
Any other Thoughts??
Thanks all!! For being patient and for helping me out here!! |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Thu Dec 29, 2005 8:54 am Post subject: |
|
|
there are a few problems with your script
i fixed what i could off hand
the problem is that it picks up "-46db" while you only want "46" ... i used the code i gave you ... also problem with the list, it can only be created once (and cannot be created again unless you close it)
| Code: |
Title Signal Strength Meter
DIALOG CREATE,802.11a/b/g WiFi Signal Strength,-1,0,300,415,NOSYS
rem *** Modified by Dialog Designer on 12/21/2005 - 16:48 ***
DIALOG ADD,BUTTON,SIGNAL,15,15,100,100,Start,Start Signal Aquisition,HAND
DIALOG ADD,BUTTON,EXIT,15,185,100,100,Exit,Close Program,HAND
DIALOG ADD,LEVEL,RSSI,125,15,99,253,0
DIALOG ADD,STATUS,%P,%P
DIALOG ADD,TIME,TIME,355,150,100,30
DIALOG SHOW
list create,1
:Evloop
wait event, 1
goto @event()
:TIMER
:SIGNALBUTTON
# RUNH c:\script1.bat,1
%%data_file = C:\my documents\TEST.TXT
list loadfile,1,%%data_file
rem assuming first line is latest entry and assuming the data file is never empty
list seek,1,0
rem change the field separator to : to parse the field contents based on that separator
rem then set the appropriate field to the variable %%data
%%dummy = @item(1)
%%data = @substr(@item(1),46,47)
rem info Signal Level: @trim(%%data)
dialog set,rssi,%%data
goto evloop
:EXITBUTTON
:close
list close, 1
exit
|
serge _________________
|
|
| Back to top |
|
 |
kc7aad Contributor

Joined: 09 Oct 2005 Posts: 53 Location: Spokane Washington
|
Posted: Thu Dec 29, 2005 7:24 pm Post subject: |
|
|
Well.. Still nothing!! I am getting nothing however now, rather than setting the DIALOG SET function!! It keeps starting another instance of the script.bat file that is usd to get the .txt file input.
Maybe I'll have to send you the script file so you can have it run as well, and make sure it is not something I am stll doing wrong!!
Thanks
kc7aad |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Thu Dec 29, 2005 11:40 pm Post subject: |
|
|
just realised, i had to change the path to TEST.TXT
i have changed it back to your original path
| Code: |
Title Signal Strength Meter
DIALOG CREATE,802.11a/b/g WiFi Signal Strength,-1,0,300,415,NOSYS
rem *** Modified by Dialog Designer on 12/21/2005 - 16:48 ***
DIALOG ADD,BUTTON,SIGNAL,15,15,100,100,Start,Start Signal Aquisition,HAND
DIALOG ADD,BUTTON,EXIT,15,185,100,100,Exit,Close Program,HAND
DIALOG ADD,LEVEL,RSSI,125,15,99,253,0
DIALOG ADD,STATUS,%P,%P
DIALOG ADD,TIME,TIME,355,150,100,30
DIALOG SHOW
list create,1
:Evloop
wait event, 1
goto @event()
:TIMER
:SIGNALBUTTON
# RUNH c:\script1.bat,1
%%data_file = C:\TEST.TXT
list loadfile,1,%%data_file
rem assuming first line is latest entry and assuming the data file is never empty
list seek,1,0
rem change the field separator to : to parse the field contents based on that separator
rem then set the appropriate field to the variable %%data
%%dummy = @item(1)
%%data = @substr(@item(1),46,47)
rem info Signal Level: @trim(%%data)
dialog set,rssi,%%data
goto evloop
:EXITBUTTON
:close
list close, 1
exit
|
i had to change the path because i am running xp and was logged in as a peasant and so could not create and save a file in c:\ ... is this the case for you too?
i ran the script above (with the change of path to where i had a sample test.txt) and it worked fine ... but without the program that generates the test.txt, it's hard to go further
one thing to check, are the new entries added at the top of the txt file or at the bottom?
serge _________________
|
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Fri Dec 30, 2005 6:55 am Post subject: |
|
|
| kc7aad wrote: | | It keeps starting another instance of the script.bat file that is usd to get the .txt file input. |
If script.bat does it's thing and then should close you need to add EXIT to the end of the script.
But if the script.bat file runs continuously you need to change part of Serge's code from this:
| Code: |
:TIMER
:SIGNALBUTTON
# RUNH c:\script1.bat,1
%%data_file = C:\TEST.TXT |
To this:
| Code: |
:SIGNALBUTTON
RUNH c:\script.bat
:TIMER
%%data_file = C:\TEST.TXT |
And make sure you change the C:\TEST.TXT above to the path/file that your script.bat outputs to. _________________ cheers
Dave |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|