Page 1 of 1 1
Topic Options
#114743 - 2004-02-25 05:04 AM find, findstr, grep, awk type functions
Everyone Offline
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
#114744 - 2004-02-25 07:37 AM Re: find, findstr, grep, awk type functions
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not sure what difficulty you have with find, works fine for many of us
indeed, to have some control over the read and write, that's must!

also the file-open mode (text/binary) is needed as can't edit even ntbackup textfiles with current capabilities.

inbuild text searches, well... not sure if I vote for those, but doh, they can't be done before basic upgrade of the "file-engine".
_________________________
!

download KiXnet

Top
#114745 - 2004-02-25 10:41 AM Re: find, findstr, grep, awk type functions
Richard H. Administrator Offline
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 Offline
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
#114747 - 2004-02-25 09:48 PM Re: find, findstr, grep, awk type functions
Everyone Offline
Getting the hang of it

Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
Lonkero got it.. totally agree with what he said.

Richard sounds like he's saying you should have to do everything the hard way. I was only using those utilities as examples of the functionality I'd like to see. They do similar functions.

Bryce.. I only had problems with the find command, because of the way it uses quotes. That looks like it'd work.. I was putting the ' in the wrong place.

Top
#114748 - 2004-02-26 12:25 PM Re: find, findstr, grep, awk type functions
Richard H. Administrator Offline
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
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 718 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.056 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org