#38576 - 2003-04-01 12:07 AM
Find command
|
sandrobpat
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
Anyone have an idea ?
Thanks.
|
|
Top
|
|
|
|
#38577 - 2003-04-01 12:13 AM
Re: Find command
|
MCA
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.
|
|
Top
|
|
|
|
#38578 - 2003-04-01 12:18 AM
Re: Find command
|
sandrobpat
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
   
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
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.
|
|
Top
|
|
|
|
#38581 - 2003-03-31 01:42 PM
Re: Find command
|
sandrobpat
Fresh Scripter
Registered: 2002-07-18
Posts: 27
Loc: A PARIS...
|
Thanks a lot to you. i understand now. Bye
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 857 anonymous users online.
|
|
|