Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / read string nub question

Author
Message
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 3rd Dec 2008 08:50 Edited at: 3rd Dec 2008 09:44
Using older version of dbpro atm been away from it for about 2-3years or more and having trouble with a little project im working on
if your using xp not vista might have to change cmd to command

Basically it opens a dos prompt, sends some commands to it to get the current running services on the pc. then outputs them to the d drive in a text file called d.txt
all i want to do is read the text file and see if a word matches a preset variable and or word

example:

read string "hello world"
check to see if "hello world" is what im looking for if it is then do something.

ty for any assistance. respons time might be aroung 12 hour

A child's dream never dies.
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 3rd Dec 2008 19:59 Edited at: 3rd Dec 2008 20:00
basically take all the dos stuff out of the equation


so basically data$ is everything in my text file im opening to read.
as it loops it goes through the list and reads everything in the file and print it to screen that part works. but i want to use an if statements to check and see if the item being currently read is what i am looking for. just think of it as a program thats supposed to search a text file for one specific word with no user input

A child's dream never dies.
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 4th Dec 2008 00:52 Edited at: 4th Dec 2008 00:56
Don't think i can be any more clear man. best I can do

the data$="windows firewall" doesn't work in my source at all
it wont compare anything it just keeps looping the program and doesnt end when it reads "windows firewall"

all i want to do is read a text file and search for a word if a word is found then "do something"

A child's dream never dies.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Dec 2008 16:30
Quote: "the data$="windows firewall" doesn't work in my source at all"

Of course it doesn't. Look at the whole line being output by 'net start'.

First of all, there are 3 spaces at the start of the line.
Next, the text isn't 'windows firewall', it's 'Windows Firewall'. When you use the equals to compare, it's looking for an exact match, not a 'well, it kinda looks like this' type match.
Finally, you aren't checking to see if you've hit the end of file either.

Here's the method I'd use:


smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 13th Dec 2008 09:42
Ianm thank you. was exactly what i needed. dont know how i missed the spaces at the beginning either pretty obvious id recon

A child's dream never dies.

Login to post a reply

Server time is: 2024-09-27 22:23:54
Your offset time is: 2024-09-27 22:23:54