Page 1 of 1 1
Topic Options
#38576 - 2003-04-01 12:07 AM Find command
sandrobpat Offline
Fresh Scripter

Registered: 2002-07-18
Posts: 27
Loc: A PARIS...
Hello,

i want to use the nt command find in a kix file, but all i test fail.
The syntax of the command under the command line
is:
find "chain" infile > result.txt

i want to use it in a kix file, and i put it as :
$chain="xxx"
shell "find "$chain" file.txt > result.txt"

Bouuuh, it doesn't work [Frown]

Anyone have an idea ?

Thanks.

Top
#38577 - 2003-04-01 12:13 AM Re: Find command
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Your problem is the quotations.
We suggestion following format
code:
$chain="xxx"
shell '%comspec% /c find "$chain" file.txt > result.txt '

greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#38578 - 2003-04-01 12:18 AM Re: Find command
sandrobpat Offline
Fresh Scripter

Registered: 2002-07-18
Posts: 27
Loc: A PARIS...
Thanks MCA, it's work...but i don't understand why because in the help file, the shell command is use with " " :
shell "..."

??

Top
#38579 - 2003-03-31 01:27 PM Re: Find command
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The problem is that you have delimited the string with the double-quote character ("), but you also want to include it in the string. When KiXtart encouters ths " character around $chain it terminates the string and therefore doesn't work.

You could have written the line either as:
code:
shell "find "+Chr(34)+$chain+Chr(34)+" file.txt > result.txt"

or
code:
shell "find "+'"'+$chain+'"'+" file.txt > result.txt"

But these are ugly - MCAs solution is neater.

Either quote can be used with Shell, there is no difference in how they work.

Your other problem (which MCA silently fixed) is that redirection using the ">" character is a DOS command shell semantic. This means that you have to run the command under the control of the DOS command shell which is why MCA used "%COMSPEC% /C" in the string.

Top
#38580 - 2003-03-31 01:28 PM Re: Find command
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Your statement:

shell "find "$chain" file.txt > result.txt"

will be interpretated as

SHELL "find"
$chain
"file.txt >result.txt"

which will show

1. find help menu
2. value of variable $chain
3. the text as file.txt >result.txt on the same line.

You shouldn't forget that ', ", $ and @ are special symbols in kixtart.
For a good story see FAQ topic Not quite everything you wanted to know about RUN and SHELL
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#38581 - 2003-03-31 01:42 PM Re: Find command
sandrobpat Offline
Fresh Scripter

Registered: 2002-07-18
Posts: 27
Loc: A PARIS...
Thanks a lot to you.
i understand now.
Bye

Top
#38582 - 2003-03-31 05:37 PM Re: Find command
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You can also use the IsStringInFile() - Checks whether a string is present in a file UDF from the UDF Forum.
_________________________
There are two types of vessels, submarines and targets.

Top
#38583 - 2003-03-31 05:40 PM Re: Find command
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
One thing overlooked in the examples is the need for %comspec% for support of redirect.

No %comspec% no redirect!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 735 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.056 seconds in which 0.023 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