-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pass batch variables to expect script? #27
Comments
@lazna : Does this code satisfy your needs ? local login = os.getenv("login")
local passwd = os.getenv("passwd")
expect( "login as:")
send( login .. "\r")
expect( login .. "@10.10.10.1's password:")
send( passwd .. "\r") |
Thanks, it work. edited my question with adding %hostname% variable, could you please edit your answer accordingly? Also extending documentation with more examples will be good. And possiobly explain syntax (vars, doubledots, doublequotes) could be great! |
The syntax which replaces the variable name to its value in the string-literal does not exist. Expect.Lua's syntax is exactly same as the programming language Lua 5.1 except for some functions described in readme.md. I can not agree explaining the Lua's syntax as my small tool's document because it is too big and Lua-VM is not my product. However, I should add the link to the Lua's offcial page in readme.md to tell users syntax. I am goint to do it. |
As never see LUA language and there are doubledots in your example, reading the ""concat": the .. (concatenation) operation." section of manual you linked, but did not make sense to me :-/ So trying blind shoot BTW: If there are single quote or other special character in the prompt text, does it need to be escaped by backslash? |
The doubledots operator is introduced in 2.5.4 – Concatenation.
The Special characters are \ and quotations.
(from 2.1 – Lexical Conventions ) |
Thanks, it works!
...and like Thanks for explanation... |
have username and password stored in bach variables and want to pass it to EXPECT script:
is something like this possible at all?
The text was updated successfully, but these errors were encountered: