Expect TCL Programming pProblem
Hi All,
I'm developing TCL code to enter a list of passwords into ecryptfs in order to find which password is accurate. I know the base of the password, but I'm missing the cap status and the charcters for the last two digits, but I have the possible characters narrowed down. The bottom line is a I have about 200-250 password I need to feed into ecryptfs. I coded the following and I will explain the resulting error at the end of the code Code:
#!/usr/bin/expect Try to recover this directory? [Y/n]: The Expect response should be "Y" Then ecryptfs asks: Do you know your LOGIN passphrase? [Y/n] The Expect response should be "Y" Then it asks: Passphrase: The Expect response should be to enter the current password in the list. The result: "Try to recover this directory? [Y/n]: " is displayed in the terminal and nothing happens until it times out. If I enter the Y, nothing happens until it times out. The first password int he list is displayed in the terminal afer it times out. I think the problem likely lies here: "if {"Try to recover this directory? [Y/n]: "}" My guess is it should be in the form: "if {$return_var = "Try to recover this directory? [Y/n]: "}" or some such. I can't find anything to guide my way, so any help is appreciated. TIA... |
Update - I used the autoexpect program to help me dial in the details of my code. I have a working version that cycles through ecryptfs password input and I will post it below.
First, though, I have three questions. 1. I want to create a list in TCL that isn't all on one line. set pwlist[list item1 item2 --what goes here so that a new line isn't registered-- item3 item4] The items in this list would be item1, item2, item3 and item4. I tried a \ character, but that didn't work. 2. I don't know what output will come when the right password is entered. What code in TCL will abort the program once unidentified program output is encountered? On to the code that is working as (1. as long as the list text is all on one line and 2. I don't know what will happen when the right password is input... will the program abort or will it continue on? I don't know) 3. Some of the passwords I tested had a $ character in them, but expect choked because it thought it was an unassigned variable. How can I fix this? Code:
#!/usr/bin/expect -f |
I've found solutions to two of the three problems:
1. I want to create a list in TCL that isn't all on one line. set pwlist[list item1 item2 --what goes here so that a new line isn't registered-- item3 item4] Answer: set pwlist[list item1 item2 \ item3 item4] The pwlist list includes item1, item2, item3 and item4. The items in this list would be item1, item2, item3 and item4. I tried a \ character, but that didn't work. Update, the \ works. I received an error and assumed it was related to the \ but was probably related to not escaping the $ sign (like this: \$) 2. I don't know what output will come when the right password is entered. What code in TCL will abort the program once unidentified program output is encountered? On to the code that is working as (1. as long as the list text is all on one line and 2. I don't know what will happen when the right password is input... will the program abort or will it continue on? I don't know) No answer yet. Any guidance would be appreciated. 3. Some of the passwords I tested had a $ character in them, but expect choked because it thought it was an unassigned variable. How can I fix this? Answer: The $ sign must be escaped with the \ character. Example: \$ |
Hi All,
Please note that the set assignment is displayed as: "set pwlist[list Pass1 Pass2]" Note their should be a space between "pwlist" and "[list Pass1 Pass2]" I don't know how to make this space display correctly. |
All times are GMT -5. The time now is 08:59 AM. |