I'm using Texpad on Windows 2000 server.
I am looking for a way to "tail" a file, that is, open a file in textpad
and have it either:
1. display only the last 100 lines of the file or
2. open the file and place the cursor at the end of the file.
This would be similar to the unix command "tail -f -n"
An example given in Textpad help makes a reference to the following to open
a file in textpad at a given line number:
TEXTPAD.EXE -ac "Read me.txt"(51,20)
Is there any way to use this command to open a file with the cursor
at the end or, say, 100 lines from the end of the file?
By way of explanation, I'm making a simple HTML page of frequently
accessed Oracle database log files, and would like to "tail" them in
Texpad. Any suggestions would be welcome.
command to open file at the end of file? Tail command?
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
berkeleydb
- Posts: 2
- Joined: Tue Dec 09, 2003 1:38 pm
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
For unix tools on Windows, it's hard to beat Cygwin. I suppose you could just open the file while passing a very large number for the row parameter. I tested it out and TextPad doesn't seem to object to passing in a row that is greater than the row count of the file. i.e. textpad -ac results.html (500,1) places my cursor at the end of the file even though wc -l results.html = 189
If the file is changing often, you may run into the issue others have had with the file changed pop-up window annoying you to death. If it is a web page, or I suppose any other text page, that you are wanting to look at, you can always download Opera and point the browser at the page. It has a handy feature where you can force a reload at whatever interval you feel is needed. Simply right-click the page and follow the Reload Every menu.
If that doesn't suit your needs, post a bit more info and I suspect someone might be able to come up with more ideas.
If the file is changing often, you may run into the issue others have had with the file changed pop-up window annoying you to death. If it is a web page, or I suppose any other text page, that you are wanting to look at, you can always download Opera and point the browser at the page. It has a handy feature where you can force a reload at whatever interval you feel is needed. Simply right-click the page and follow the Reload Every menu.
If that doesn't suit your needs, post a bit more info and I suspect someone might be able to come up with more ideas.
I choose to fight with a sack of angry cats.
-
berkeleydb
- Posts: 2
- Joined: Tue Dec 09, 2003 1:38 pm
Thanks for the quick response. I agree with you on Cygwin.
Part of the problem is that I'm in a highly controlled environment where getting permission for new tools is difficult, especially shareware or freeware. We do have Textpad licenses , and I like working with Textpad anyway, so I was hoping to find a way to "tail" the log files.
I'll try your suggestion on a high line number, although these log files can be > 1 Gig at times. (How many lines are in a Gig?)
I'm hearing that Microsoft will add features to a new version of Windows in 2006 that will be more unix-like. The feature is called MSH (Microsoft shell), a type of c shell command line with pipes and everything, and hopefully Textpad will incorporate that somehow, but it doesn't do me much good for now.
Thanks......
Part of the problem is that I'm in a highly controlled environment where getting permission for new tools is difficult, especially shareware or freeware. We do have Textpad licenses , and I like working with Textpad anyway, so I was hoping to find a way to "tail" the log files.
I'll try your suggestion on a high line number, although these log files can be > 1 Gig at times. (How many lines are in a Gig?)
I'm hearing that Microsoft will add features to a new version of Windows in 2006 that will be more unix-like. The feature is called MSH (Microsoft shell), a type of c shell command line with pipes and everything, and hopefully Textpad will incorporate that somehow, but it doesn't do me much good for now.
Thanks......
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Just an untested thought.
How obout opening TextPAd with a batch/script file. In the batch file, get a line count, subtract 100 from that count and pass the results in with the TEXTPAD.EXE -ac "Read me.txt"(51,20) that you already referred to.
Example of idea: Searching for a "known bad value" will result in the line count being send to line 2 of the temp file lines.txt
find /c /v "q~q" readme.txt >>lines.txt
Two examples of Macro Scheduler script:
1. Just open the file in TextPad and move the cursor to the desired position:
How obout opening TextPAd with a batch/script file. In the batch file, get a line count, subtract 100 from that count and pass the results in with the TEXTPAD.EXE -ac "Read me.txt"(51,20) that you already referred to.
Example of idea: Searching for a "known bad value" will result in the line count being send to line 2 of the temp file lines.txt
find /c /v "q~q" readme.txt >>lines.txt
Two examples of Macro Scheduler script:
1. Just open the file in TextPad and move the cursor to the desired position:
OR this which is closer to my original suggestion:Let>Source=f:\data\readme.txt
Run Program>C:\Program Files\TextPad 4\Textpad.exe -ac "%Source%"
//Use keys to go to 100 lines from the end of the file
Press CTRL
Press END
Release CTRL
Press UP*100
I already had the Macro Scheduler script done for doing line counts, and edited it for your example. I provided it here to explain what I was thinking about. But option 1 is much cleaner. I am sure someone else can provide a different script for you.//Seek2 is set to a non-existent string
Let>Seek2=q~q
//Source is the file path\name to have the lines counted
//Can use Input to prompt for file name with full path vs. hard code
Let>Source=f:\data\readme.txt
Let>CountFile=f:\data\lines.txt
//Pipe results of FIND to a temp file
Run Program>C:\WINNT\System32\cmd.exe /c find /c /v "%Seek2%" %Source%>>%CountFile%
//Results of Find are on the second line of the temp file.
ReadLn>%CountFile%,2,Result
//Parse the line count to Result2
//Line count value is at position equal to length of Full Source path and file name, plus fourteen.
Len>%Source%,FileNameLength
Let>Position=%FileNameLength%+14
MidStr>%Result%,%Position%,5,Result2
//Subtract 100 from the line count, Result2
Sub>%Result2%-100
//Open TextPad, go to column 0 at 100 lines from the end.
Run Program>C:\Program Files\TextPad 4\Textpad.exe -ac "%Source%"(%Result2%,0)
Hope this was helpful.............good luck,
Bob
Bob