Jump to content

Recommended Posts

Posted (edited)

Hi all!

I need following help:

I have this script that accepts number as a parameter and then echoes the line from that number from file c:\account.txt. This works fine:

* check.vbs *********************

Const FOR_READING = 1

strFilePath = "C:\account.txt"

set objRe = New RegExp

objRE.Global = True

objRE.IgnoreCase = False

objRE.Pattern = WScript.Arguments(0)

iLineNumber = objRE.Pattern

Set objFS = CreateObject("Scripting.FileSystemObject")

Set objTS = objFS.OpenTextFile(strFilePath, FOR_READING)

For i=1 To (iLineNumber-1)

objTS.SkipLine

Next

WScript.Echo objTS.Readline

***********************

c:\type account.txt

one

two

three

four

five

c:\check.vbs 4

four

c:\check.vbs 2

two

I need the following:

I have a html file containing this kind of data:

***********

</p><p class="fontti">TEEMU TESTAAJA</p> <p>Vahvista sisäänkirjaus antamalla avainlukua nro 70 vastaava turvaluku</p><p><input name="turvaluku" type="password" maxlength="6" size="6" autocomplete="off" style="TxtBox" /><input name="vahvista" type="submit" class="Button155 ButtonMarginLeft10" value="Vahvista sisäänkirjaus" />

***********

I need to be able to read file, find the "70" (number between nro and vastaava, will be changing number) and use it as a parameter in the script instead of having to manually give the number. Can anyone help me?

Any help appreciated!

timo -- @ -- kiinnostaa.net

Edited by elaintarha

Posted

Is the number 70 in the account.txt if yes then something like this might help

Const FOR_READING = 1
strFilePath = "C:\account.txt"

set objRe = New RegExp
objRE.Global = True
objRE.IgnoreCase = False
objRE.Pattern = WScript.Arguments(0)

iLineNumber = objRE.Pattern

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFilePath, FOR_READING)
Dim StrValue
For i=1 To (iLineNumber-1)
If instr(objTS.Readline,70) then
'/-> StrValue Is 70
StrValue = objTS.Readline
Exit For
end if
'/-> Not Needed
' objTS.SkipLine

Next
'/-> This will only Show The Last Line Read Txt, Not Needed
' WScript.Echo objTS.Readline

Hope this is what you wanted.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...