Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 09-30-2008, 11:02 AM
djudd djudd is offline
Registered User
Join Date: Sep 2008
Posts: 3
Need to skip the first line when reading back a text file

First a disclaimer...I'm using SecureCRT 3.4....yes I know it's 2008, but I've just always used it so please forgive me.

I'm cobbling together a VBS script to automate some route work, and part of it is starting a local text file, cat'ing a file on a unix server, stopping the file, logging into a device and spitting it back out from the local copy. Here's the relevant bit:
crt.Session.Log True
crt.Screen.Send "cat /home/djudd/tmp/" & router_name & "_4.txt" & vbCr
crt.Screen.WaitForString "$"
crt.Session.Log False

Then I'm just using the text book example for reading back a locally created text file:
Const ForReading = 1
Const ForWriting = 2

Dim fso, file, str
Set fso = CreateObject("Scripting.FileSystemObject")

' Note: A runtime exception will be generated if 'input.txt' doesn't exist.
Set file = fso.OpenTextFile("c:\mysession.log", ForReading, False)

crt.Screen.Synchronous = True

Do While file.AtEndOfStream <> True

str = file.Readline
' Send the line with an appended CR
crt.Screen.Send str & Chr(13)
' Wait for my prompt before sending the next line
'crt.Screen.WaitForString "prompt$"

crt.Screen.Synchronous = False

So here's my question. The local text file created contains a grep command that I don't want spit back into the router config...any ideas on how to get it out? First I tried moving the session.log true statement until after the cat command, then I tried usin WSH to invoke a local copy of "egrep -v" but I suspect my ancient copy of SecureCRT caused that to error out....so right now I'm at a wall. I just need to skip the first line...but the file will vary in length so I dont know what line it will stop on.

Any ideas would help, thanks.
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 12:56 PM.