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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading in a text file

Status
Not open for further replies.

Matta25

Technical User
Jan 6, 2004
82
US
Is there a way to read the last 20 lines of a text file. The text file will vary in length. Can I start at the end of file and go up 20 line then read in these lines.
thanks.
 
or can i open the file and search for a string, then read in all the line from that string found to the end of the file?
 
Are the lines in the text file a constant length? If so, you could open the file, seek to the end of the file using the fseek command, and then fseek backwards in the file to get to the beginning of the 20 lines at the bottom of the file.

aspect@aspectscripting.com
 
are there any samples on how to read from the bottom?
 
There are no examples that I am aware of that meet your criteria. As for your other question (didn't show up when I posted my response), you can use the strfind command to see if a line read from the text file contains the string of text you are looking for.


aspect@aspectscripting.com
 
How do I make this work? I'm trying to see if the user input the word NPA, NXX or SPN back earlier in program.These would be assigned to the bartype veriable.
I'm trying to say IF strfind bartype is NXX or NPA or SPN then do this? with one if then statement. Is this possible or is there a better way. I'm sure this is simple but I'm just learning.I can't figure this out.
Thanks!!

sdlginput "Gathering Information..." "Enter the either NPA,NXX or SPN :" bartype 3 DEFAULT
if FAILURE
goto Quit
else
endif
if strfind bartype "NPA"|"NXX"
sdlgmsgbox "" "Do you have Deny codes?" question yesno denycode
if denycode == 6
sdlginput "In the format C:\file\denycodes.txt" "Enter the text file they are stored in." storedfile DEFAULT

else
endif
endif

Woodro
 
Hello all,
I'd like to write a script doing this
1- Using "DOS" ping command and ping a list of hosts on the same subnet.
2- Create a directory for each host in this ipaddress format 127_0_0_1.
3- Using "tftp get ip_host" to get configuration file.

Any ideas how to do this


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top