| |||||||||||
tcl proc to string match data to the stdout data Posted by deepshikha_dutta (deepshikha_dutta), 26 September 2007 Hi,I have a question , I want to create a script which will execute in the following way. tcl> regress {ls} {check "file1"} regress is a proc. "ls" is a shell command to list out all files in the directory. "check is a proc " which will string match "file1" to the data generated by "ls" Wht I want to do: ------------------------ When I will run the above format : regress will check the file "file1" from the list of files at the stdout due to "execution of ls" and will pass if the file exist or will fail if the file does not exist. Could someone help out. Regards Deep Posted by admin (Graham Ellis), 26 September 2007 So you're looking for a proc that will check whether or not the first parameter is one of the values in a list given as the second parameter? Posted by deepshikha_dutta (deepshikha_dutta), 26 September 2007 For ex:--------- "ls" on tcl prompt gives the following set of files : tcl>ls file12 file13 file23 ddd actual Now I want to search for "file1" from the above list. if match no error if not generates error. Here file1 match with both "file12 & file13" so no error. I want to exec in this manner: regress {ls} {check "file1"} note:regress & check both are proc. "ls" is the argument pass to "proc regress" and "proc check" match "file1" with the output of "ls" Regards Deep Posted by admin (Graham Ellis), 26 September 2007 Ah - so you're looking to see whether the first value if WITHIN the second.I think all you need is a string match: Code:
Which runs as Code:
Posted by deepshikha_dutta (deepshikha_dutta), 26 September 2007 Thanks, Now you have hard coded the list set within "this that file2 file19 16 bill" I have modified a little bit as follows and it works: set within [exec ls] Now You have given output as 1 & 0 . Actually I want the command regress to fail by giving out error message when string match does not happen. Regards Deep Posted by admin (Graham Ellis), 27 September 2007 on 09/26/07 at 20:10:45, deepshikha_dutta wrote:
You are very welcome to change my example code to do whatever you need Posted by deepshikha_dutta (deepshikha_dutta), 27 September 2007 Thanks for the code it is going to be helpfull.Regards debraj This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |