#114743 - 2004-02-25 05:04 AM
find, findstr, grep, awk type functions
|
Everyone
Getting the hang of it
Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
|
Looking through, can't find this as having been previously suggested.
I'd like to see built in functions similar to "find", and "findstr" in DOS, or "grep" and "awk" in Unix.
I'm finding that using shell to try and do "find" command is near impossible without putting the command in a batch file and calling the batch file. Using shell to run a findstr command has been working out ok, but it'd still be nice to have it built in.
I think I saw a UDF that expands ReadLine() to do something like this.. one for WriteLine() that does the opposite as well. That would be nice to have the expanded functionality of being able to read or write to a specific line, as well as have the option to either overwite that line, or add to either the beginning or end of the line. Or perhaps to be able to search through a document and replace a specified word.
Just some ideas.
|
Top
|
|
|
|
#114745 - 2004-02-25 10:41 AM
Re: find, findstr, grep, awk type functions
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Things like "find", "grep" and "awk" are utilities, not scripting features - awk is an entire scripting language in itself.
If you want to use these in KiXtart, download the windows compiled versions - you'll find a couple of repositories on SourceForge. If you have trouble finding them, post again in the general forum and I'll look up the link for you.
It is not appropriate to build these into KiXtart. If you were using these utilites in *nix, you would be calling them in a shell (batch) script the same way that you use "SHELL" or one of the "pipe" UDFs in KiXtart.
What would be appropriate and would resolve most of your requests would be a request for: 1) Reading application output and writing directly to application input (piping). 2) Built-in support for regular expression matching.
While it would be nice to have KiXtart friendly built-in function these requirements can already be satisfied, albeit with a little work and/or the use of existing UDFs. Search for WSHPipe for piping and Howard Bullocks efforts for regular expressions.
|
Top
|
|
|
|
#114746 - 2004-02-25 04:30 PM
Re: find, findstr, grep, awk type functions
|
Bryce
KiX Supporter
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
If i understand you correctly, you are not able to SHELL or RUN a find, findstr, or other such shell command with out putting it in a bat file?
use %comspec% /c in your SHELL/RUN commands.
example:
Code:
Shell '%comspec% /c ping 127.0.0.1 -n 1 | find "TTL" > nul' If not @ERROR ? "Ping reply was good" Else ? "Ping reply was bad" EndIf
|
Top
|
|
|
|
#114748 - 2004-02-26 12:25 PM
Re: find, findstr, grep, awk type functions
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Richard sounds like he's saying you should have to do everything the hard way.
No, you misunderstood my post.
It is not clear in your first initial post what you are actually asking for, and you are mixing this with observations about difficulties you've had using things like Shell.
My post both provides you with an immediate solution for your difficulties and attempts to clarify what featrues you think should be added to KiXtart that would help everyone who uses it.
Things like sed, grep and awk have some great facilities, many of which would be very useful in KiXtart, but not everyone knows these utilities or which particular features you would find useful.
Try organising your request into a bullet point list of specific features that you think would be generally useful in KiXtart. Try to simplify each feature as far as possible so that it describes a definite action. If you cannot do it in a single short sentence then it probably isn't appropriate.
For example, from your posts we can assume that you would like to see:
- Support for extended pattern matching (regular expressions) for KiXtart basic data types
- Support for reading a specific line in a text file
- Support for writing (to) a specific line in a text file
- Support for deleting a specific line in a text file
- Support for inserting a new line in a text file
- Support for reading the ouput of SHELL'ed commands
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 496 anonymous users online.
|
|
|