I am new to expect and trying to get hands on it. I have not found much of documentation and so here I am looking for some help from the forums.
I am trying to generate a table which is dumped on the screen (similar to output from ps command ).After adding/ deleting a row from the table i have to verify the output using expect. Also how to verify the output of all the rows from the table. Any help or suggestions would be great.
Thanks and Regards,
If the first step is to verify that the row you deleted was successful and there isn't some built in verification to the process you're using then you could dump the table to the screen and expect the row you deleted so if it finds it then you know it didn't work and if it doesn't find it then you're good.
Now for checking the whole table it depends on if you're checking for exact numbers that you can put into the script or if the numbers change alot then you'd have to expect using regular expressions.
It's all possible but just depends on what you actually need to check for. When you look at it manually what are you looking for?
Actually, i got the logic and would be doing the same as you have specified when a row is deleted. But i am looking for how to use a regular expression to check the whole table or the rows in a table. For example my table output would be as follows.
+col1 | col2 | col3 +
+ str1| num1| str2 +
+str3 | num2 | str2 +
In the above col1 and col3 accept string values and col2 accepts numeric values. so when i add a row 1
i have to check for the str1,num1,str2 to be present in first row and similarly str3,num2,str2 are present in the 2nd row.
I had actually started looking into expect last week and ordered the book exploring expect . Before i get the book i trying to look at some examples or tutorials on regular expressions and matching patterns . But couldnt find it . Hope you got some idea what i am looking for. Appreicate your response. Thanks
That's good you've got the book coming, it's the best documentation out there for expect. It seems like you might know the exact values you need to look for so you wouldn't need regular expressions but if you do then it's just a matter of finding the right expression and putting it into the expect statement. I'm not a regex guru but I've found lots of useful ones online.
It may be useful to use the autoexpect script that comes with expect to capture you running the command and getting the table output. Then you can go in an edit the script it creates to be exactly what you need.
Thanks for your reply. My output will be separated by new line charachters depending on the number of rows of the table. Once i send a command through send i should be getting some output on my stdout.Which expect command should be used so that i can capture the total output inside a buffer.Also once i captured in the buffer i have to search for the patterns in the buffer accordingly. Is there any command so that i can extract a sub pattern from the total string in the buffer and compare it. I am just trying to get more information by discussion. Being a newbie to TCL and Expect, I know i am asking very simple questions.
I would be looking into autoexpect soon. But got the book just now and would be exploring it a lot and try to grab as much information as possible.I will keep posting in this forum although. Thanks for your advice .