Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove trailing characters.. 1

Status
Not open for further replies.

ErroR

Technical User
Apr 9, 2001
79
0
0
US
I'm trying to get the ping results that are written to a .txt file fed into a variable. I'm using SkipLine and Skip to get to the "Time" results for the reply and I don't know how to get just the two or three digits of the reply. I can get up to the digits, but then I am doing ReadLine and that gets the digits plus the rest of the text in the line (which is something like TTL=120)

I can do a case or an if to evaluate the statement and turn the variable into what I want, like this:

i = oFSO.Readline
if i = "10ms TTL=120" then
i = "10"
else blah blah blah

The bad thing is, when I do the ReadLine, it catches the EOL character so that IF statement never works because I can't key in the EOL character.

So I'm totally open to any suggestions here.. I'm sure there is a better way. Or just someone can suggest how to trim everything after the last digit, be it a 2 or 3 digit result...

Thanks
 
if you know how much of the line you want, then you can use the left() function:

string = "Pooh"
string = left(string, 3)
response.write(string)

output:
Poo

:)
Paul Prewett
 
You could try using Instr to search each readline for the segment you are looking for. Or you could use the Trim commands to get rid of trailing space.
sStrng2Find="10ms TTL=120"
Do Until oTxtStream1.AtEndOfStream
sStrng2Srch=oTxtStream1.Readline
If Instr(11, sStrng2Srch, sStrn2Find, 1) > 0 then...
Loop

Best of Luck Greg Armstrong
A+ MCSE+I :)
 
link9 that is exactly what I needed. I knew something had to be there to make that work.

In fact, I'll I'm interested in is whether or not the ping was replied. So the first word on each line is either "Reply" or "Request" as in "Reply from blah blah" or "Request Timed Out"

So I just used the Left function to capture the first 5 characters and then do an if statement evaluate did it reply or time out. Works great.

Why oh why is there not a ping type functionality built into scripting?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top