Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Returning a line from an input file using vbscript

Reply
 
Old 05-08-2009   #1 (permalink)
charlotte.bruteig


 
 

Returning a line from an input file using vbscript

HI
I have a list with lines, that contains an ip adress for each line.
I want to make a query for a ip adress, and get the whole line as a
result.

I have no ideas, so I hope if someone please can help me fast?

/Catinka

My System SpecsSystem Spec
Old 05-08-2009   #2 (permalink)
billious


 
 

Re: Returning a line from an input file using vbscript


<charlotte.bruteig@xxxxxx> wrote in message
news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
Quote:

> HI
> I have a list with lines, that contains an ip adress for each line.
> I want to make a query for a ip adress, and get the whole line as a
> result.
>
> I have no ideas, so I hope if someone please can help me fast?
>
> /Catinka
From the prompt,

find "123.45.67.8" <"filename containing list.txt" >"filename for
results.txt"

where 123.45.67.8 is the IP address you want to retrieve, and
Quote:

>"filename for results.txt"
is optional - if omitted, result will be displayed on-screen.


My System SpecsSystem Spec
Old 05-08-2009   #3 (permalink)
Pegasus [MVP]


 
 

Re: Returning a line from an input file using vbscript


<charlotte.bruteig@xxxxxx> wrote in message
news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
Quote:

> HI
> I have a list with lines, that contains an ip adress for each line.
> I want to make a query for a ip adress, and get the whole line as a
> result.
>
> I have no ideas, so I hope if someone please can help me fast?
>
> /Catinka
Here you go:
@echo off
type c:\List.txt | find "192.168.55.18"

Fast enough?

You probably need to spend a little more time in defining your requirements,
in particular by stating
- Where does the IP address come from? Fixed? User prompt? Some text file?
- Where is the output line supposed to go to? Pop-up panel? Console screen?
File?
- What do you expect when the IP address is not found?
The quality of the replies you get is directly related to the quality of
your query.


My System SpecsSystem Spec
Old 05-08-2009   #4 (permalink)
charlotte.bruteig


 
 

Re: Returning a line from an input file using vbscript

On 8 Mai, 23:53, "billious" <billious_1...@xxxxxx> wrote:
Quote:

> <charlotte.brut...@xxxxxx> wrote in message
>
> news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
>
Quote:

> > HI
> > I have a list with lines, that contains an ip adress for each line.
> > I want to make a query for a ip adress, and get the whole line as a
> > result.
>
Quote:

> > I have no ideas, so I hope if someone please can help me fast?
>
Quote:

> > /Catinka
>
> From the prompt,
>
> find "123.45.67.8" <"filename containing list.txt" >"filename for
> results.txt"
>
> where 123.45.67.8 is the IP address you want to retrieve, and>"filename for results.txt"
>
> is optional - if omitted, result will be displayed on-screen.
Thanks!!! It did its work!!
My System SpecsSystem Spec
Old 05-08-2009   #5 (permalink)
Al Dunbar


 
 

Re: Returning a line from an input file using vbscript


<charlotte.bruteig@xxxxxx> wrote in message
news:83026766-a8d6-4f53-a996-a718a913f368@xxxxxx
Quote:

> On 8 Mai, 23:53, "billious" <billious_1...@xxxxxx> wrote:
Quote:

>> <charlotte.brut...@xxxxxx> wrote in message
>>
>> news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
>>
Quote:

>> > HI
>> > I have a list with lines, that contains an ip adress for each line.
>> > I want to make a query for a ip adress, and get the whole line as a
>> > result.
>>
Quote:

>> > I have no ideas, so I hope if someone please can help me fast?
>>
Quote:

>> > /Catinka
>>
>> From the prompt,
>>
>> find "123.45.67.8" <"filename containing list.txt" >"filename for
>> results.txt"
>>
>> where 123.45.67.8 is the IP address you want to retrieve, and>"filename
>> for results.txt"
>>
>> is optional - if omitted, result will be displayed on-screen.
>
> Thanks!!! It did its work!!
Funny, but that doesn't look at all like vbscript code...

/Al


My System SpecsSystem Spec
Old 05-08-2009   #6 (permalink)
Al Dunbar


 
 

Re: Returning a line from an input file using vbscript


"Pegasus [MVP]" <news@xxxxxx> wrote in message
news:u%23IZXhC0JHA.5728@xxxxxx
Quote:

>
> <charlotte.bruteig@xxxxxx> wrote in message
> news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
Quote:

>> HI
>> I have a list with lines, that contains an ip adress for each line.
>> I want to make a query for a ip adress, and get the whole line as a
>> result.
>>
>> I have no ideas, so I hope if someone please can help me fast?
>>
>> /Catinka
>
> Here you go:
> @echo off
> type c:\List.txt | find "192.168.55.18"
>
> Fast enough?
>
> You probably need to spend a little more time in defining your
> requirements, in particular by stating
> - Where does the IP address come from? Fixed? User prompt? Some text file?
> - Where is the output line supposed to go to? Pop-up panel? Console
> screen? File?
> - What do you expect when the IP address is not found?
Another question worth asking: why ask for a batch solution in a vbscript
newsgroup?

/Al


My System SpecsSystem Spec
Old 05-09-2009   #7 (permalink)
torgeir.schjerven


 
 

Re: Returning a line from an input file using vbscript

On 9 Mai, 01:55, "Al Dunbar" <aland...@xxxxxx> wrote:
Quote:

> "Pegasus [MVP]" <n...@xxxxxx> wrote in message
>
> news:u%23IZXhC0JHA.5728@xxxxxx
>
>
>
>
>
>
>
Quote:

> > <charlotte.brut...@xxxxxx> wrote in message
> >news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
Quote:

> >> HI
> >> I have a list with lines, that contains an ip adress for eachline.
> >> I want to make a query for a ip adress, and get the wholelineas a
> >> result.
>
Quote:
Quote:

> >> I have no ideas, so I hope if someone please can help me fast?
>
Quote:
Quote:

> >> /Catinka
>
Quote:

> > Here you go:
> > @echo off
> > type c:\List.txt | find "192.168.55.18"
>
Quote:

> > Fast enough?
>
Quote:

> > You probably need to spend a little more time in defining your
> > requirements, in particular by stating
> > - Where does the IP address come from? Fixed? User prompt? Some text file?
> > - Where is the outputlinesupposed to go to? Pop-up panel? Console
> > screen? File?
> > - What do you expect when the IP address is not found?
>
> Another question worth asking: why ask for a batch solution in avbscript
> newsgroup?
>
> /Al– Skjul sitert tekst –
>
> – Vis sitert tekst –
I would like to accomplish this using vbscript. But I can not either
get it to work.
I am thinking of just having an input box to specify the IP adress, or
maybe an input file with severeal IP's
And then return the hole line(s) that contains that IP.

I am a newbie at scripting so if anyone has a nice example it would
help me understand it.
The result I want to have in an output file or only in the console.

Kind Regards
Torgeir


My System SpecsSystem Spec
Old 05-09-2009   #8 (permalink)
torgeir.schjerven


 
 

Re: Returning a line from an input file using vbscript

On 9 Mai, 01:55, "Al Dunbar" <aland...@xxxxxx> wrote:
Quote:

> "Pegasus [MVP]" <n...@xxxxxx> wrote in message
>
> news:u%23IZXhC0JHA.5728@xxxxxx
>
>
>
>
>
>
>
Quote:

> > <charlotte.brut...@xxxxxx> wrote in message
> >news:831e7683-7a38-4fff-8498-d5b1788060ce@xxxxxx
Quote:

> >> HI
> >> I have a list with lines, that contains an ip adress for eachline.
> >> I want to make a query for a ip adress, and get the wholelineas a
> >> result.
>
Quote:
Quote:

> >> I have no ideas, so I hope if someone please can help me fast?
>
Quote:
Quote:

> >> /Catinka
>
Quote:

> > Here you go:
> > @echo off
> > type c:\List.txt | find "192.168.55.18"
>
Quote:

> > Fast enough?
>
Quote:

> > You probably need to spend a little more time in defining your
> > requirements, in particular by stating
> > - Where does the IP address come from? Fixed? User prompt? Some text file?
> > - Where is the outputlinesupposed to go to? Pop-up panel? Console
> > screen? File?
> > - What do you expect when the IP address is not found?
>
> Another question worth asking: why ask for a batch solution in avbscript
> newsgroup?
>
> /Al– Skjul sitert tekst –
>
> – Vis sitert tekst –
I would like to accomplish this using vbscript. But I can not either
get it to work. I am thinking of just having an inputbox to specify
the IP adress, or
maybe an input file with severeal IP's
And then return the hole line(s) that includes the specified IP.

I am a newbie at scripting so if anyone has a nice example it would
help me understand it.
The result I want to have in an output file or only in the console.


My IP file looks like something like this:
Windows_NetServer;app.a.b.c.no;10.0.0.17
Windows_NetServer;db.a.b.c.no;10.0.0.18
Windows_NetServer;db.a.b.c.no;10.0.0.19
Windows2000_Server;app.a.b.c.no;10.0.0.20
Windows_NetServer;fil.a.b.c.no;10.0.0.21
Windows_NetServer;db.a.b.c.no;10.0.0.22


Torgeir

My System SpecsSystem Spec
Old 05-09-2009   #9 (permalink)
Pegasus [MVP]


 
 

Re: Returning a line from an input file using vbscript


<torgeir.schjerven@xxxxxx> wrote in message
news:baee0192-0f4d-4a41-bac5-4838b88e4be2@xxxxxx
On 9 Mai, 01:55, "Al Dunbar" <aland...@xxxxxx> wrote:
Quote:

> "Pegasus [MVP]" <n...@xxxxxx> wrote in message
>
I would like to accomplish this using vbscript. But I can not either
get it to work. I am thinking of just having an inputbox to specify
the IP adress, or
maybe an input file with severeal IP's
And then return the hole line(s) that includes the specified IP.

I am a newbie at scripting so if anyone has a nice example it would
help me understand it.
The result I want to have in an output file or only in the console.


My IP file looks like something like this:
Windows_NetServer;app.a.b.c.no;10.0.0.17
Windows_NetServer;db.a.b.c.no;10.0.0.18
Windows_NetServer;db.a.b.c.no;10.0.0.19
Windows2000_Server;app.a.b.c.no;10.0.0.20
Windows_NetServer;fil.a.b.c.no;10.0.0.21
Windows_NetServer;db.a.b.c.no;10.0.0.22

Torgeir
===============

Here you go:

Set oFSO = CreateObject("Scripting.FileSystemObject")
sIP = InputBox("Please enter an IP address", "Extract Address")
Set oFile = oFSO.OpenTextFile("d:\IP.txt", 1)
sData = oFile.ReadAll
oFile.Close
aData = Split(sData, VbCrLf)
For Each sLine In aData
If InStr(sLine, sIP) > 0 then WScript.Echo sLine
Next

I recommend that you download the help file script56.chm. It covers
everything I used in the code above, plus lots more, plus numerous examples.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Line input perfect - mic (using same socket) V. low Sound & Audio
Output XML to Single Line Log File using VBScript VB Script
Past vbscript input box text to the end of url VB Script
Input panel: Does not advance next line Vista General
Command Line Input? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46