Expect script multiple Q/A
I have the following expect script:
#!/usr/bin/expect
set timeout 20
set cmd "/path/vpntool --server 1.2.3.4:443 --vpnuser user"
set password [lindex $argv 0]
eval spawn $cmd
expect "VPN:"
send "$passwordr";
interact
expect ".*(Y/N)"
send "Yr";
interact
The scripts stops at the question "Would you like to connect to this server? (Y/N)" waits for the answer.
Does anybody know what could be the problem?
expect
add a comment |
I have the following expect script:
#!/usr/bin/expect
set timeout 20
set cmd "/path/vpntool --server 1.2.3.4:443 --vpnuser user"
set password [lindex $argv 0]
eval spawn $cmd
expect "VPN:"
send "$passwordr";
interact
expect ".*(Y/N)"
send "Yr";
interact
The scripts stops at the question "Would you like to connect to this server? (Y/N)" waits for the answer.
Does anybody know what could be the problem?
expect
Error: “Would you like to connect to this server? (Y/N)” not found in script. I assume that it comes from an external command. Therefore you will have to give us some more information.
– ctrl-alt-delor
Feb 7 at 11:30
The question comes from /path/vpntool binary which the Forticlient SSL VPN client. The second question comes on stdout only after the first value(password) is accepted. And it it usually comes with an delay smaller than 1 sec . I've also tried with "Would you like to connect to this server? (Y/N)" instead of the regex, and still doesn't work...
– Spike.WD
Feb 7 at 11:59
I note you escaped the/
. Is that the cause? OR maybe you need to sendYn
.
– ctrl-alt-delor
Feb 7 at 12:05
After the password is accepted an expired certificate infos are dumped on stdout and the last line is "Would you like to connect to this server? (Y/N)" ... Maybe it could be a problem the fact that the question contains many lines...
– Spike.WD
Feb 7 at 12:48
Is there a reason that you have aninteract
before your secondexpect
command? That interact doesn't have a return condition, so theexpect ".*(Y/N)"
is never reached... Also: the/
character isn't special to regular expressions and doesn't need to be escaped, and the.*
at the beginning of the expect pattern is extraneous.
– This isn't my real name
Feb 7 at 17:00
add a comment |
I have the following expect script:
#!/usr/bin/expect
set timeout 20
set cmd "/path/vpntool --server 1.2.3.4:443 --vpnuser user"
set password [lindex $argv 0]
eval spawn $cmd
expect "VPN:"
send "$passwordr";
interact
expect ".*(Y/N)"
send "Yr";
interact
The scripts stops at the question "Would you like to connect to this server? (Y/N)" waits for the answer.
Does anybody know what could be the problem?
expect
I have the following expect script:
#!/usr/bin/expect
set timeout 20
set cmd "/path/vpntool --server 1.2.3.4:443 --vpnuser user"
set password [lindex $argv 0]
eval spawn $cmd
expect "VPN:"
send "$passwordr";
interact
expect ".*(Y/N)"
send "Yr";
interact
The scripts stops at the question "Would you like to connect to this server? (Y/N)" waits for the answer.
Does anybody know what could be the problem?
expect
expect
edited Feb 7 at 11:27
ctrl-alt-delor
11.5k42059
11.5k42059
asked Feb 7 at 11:17
Spike.WDSpike.WD
294
294
Error: “Would you like to connect to this server? (Y/N)” not found in script. I assume that it comes from an external command. Therefore you will have to give us some more information.
– ctrl-alt-delor
Feb 7 at 11:30
The question comes from /path/vpntool binary which the Forticlient SSL VPN client. The second question comes on stdout only after the first value(password) is accepted. And it it usually comes with an delay smaller than 1 sec . I've also tried with "Would you like to connect to this server? (Y/N)" instead of the regex, and still doesn't work...
– Spike.WD
Feb 7 at 11:59
I note you escaped the/
. Is that the cause? OR maybe you need to sendYn
.
– ctrl-alt-delor
Feb 7 at 12:05
After the password is accepted an expired certificate infos are dumped on stdout and the last line is "Would you like to connect to this server? (Y/N)" ... Maybe it could be a problem the fact that the question contains many lines...
– Spike.WD
Feb 7 at 12:48
Is there a reason that you have aninteract
before your secondexpect
command? That interact doesn't have a return condition, so theexpect ".*(Y/N)"
is never reached... Also: the/
character isn't special to regular expressions and doesn't need to be escaped, and the.*
at the beginning of the expect pattern is extraneous.
– This isn't my real name
Feb 7 at 17:00
add a comment |
Error: “Would you like to connect to this server? (Y/N)” not found in script. I assume that it comes from an external command. Therefore you will have to give us some more information.
– ctrl-alt-delor
Feb 7 at 11:30
The question comes from /path/vpntool binary which the Forticlient SSL VPN client. The second question comes on stdout only after the first value(password) is accepted. And it it usually comes with an delay smaller than 1 sec . I've also tried with "Would you like to connect to this server? (Y/N)" instead of the regex, and still doesn't work...
– Spike.WD
Feb 7 at 11:59
I note you escaped the/
. Is that the cause? OR maybe you need to sendYn
.
– ctrl-alt-delor
Feb 7 at 12:05
After the password is accepted an expired certificate infos are dumped on stdout and the last line is "Would you like to connect to this server? (Y/N)" ... Maybe it could be a problem the fact that the question contains many lines...
– Spike.WD
Feb 7 at 12:48
Is there a reason that you have aninteract
before your secondexpect
command? That interact doesn't have a return condition, so theexpect ".*(Y/N)"
is never reached... Also: the/
character isn't special to regular expressions and doesn't need to be escaped, and the.*
at the beginning of the expect pattern is extraneous.
– This isn't my real name
Feb 7 at 17:00
Error: “Would you like to connect to this server? (Y/N)” not found in script. I assume that it comes from an external command. Therefore you will have to give us some more information.
– ctrl-alt-delor
Feb 7 at 11:30
Error: “Would you like to connect to this server? (Y/N)” not found in script. I assume that it comes from an external command. Therefore you will have to give us some more information.
– ctrl-alt-delor
Feb 7 at 11:30
The question comes from /path/vpntool binary which the Forticlient SSL VPN client. The second question comes on stdout only after the first value(password) is accepted. And it it usually comes with an delay smaller than 1 sec . I've also tried with "Would you like to connect to this server? (Y/N)" instead of the regex, and still doesn't work...
– Spike.WD
Feb 7 at 11:59
The question comes from /path/vpntool binary which the Forticlient SSL VPN client. The second question comes on stdout only after the first value(password) is accepted. And it it usually comes with an delay smaller than 1 sec . I've also tried with "Would you like to connect to this server? (Y/N)" instead of the regex, and still doesn't work...
– Spike.WD
Feb 7 at 11:59
I note you escaped the
/
. Is that the cause? OR maybe you need to send Yn
.– ctrl-alt-delor
Feb 7 at 12:05
I note you escaped the
/
. Is that the cause? OR maybe you need to send Yn
.– ctrl-alt-delor
Feb 7 at 12:05
After the password is accepted an expired certificate infos are dumped on stdout and the last line is "Would you like to connect to this server? (Y/N)" ... Maybe it could be a problem the fact that the question contains many lines...
– Spike.WD
Feb 7 at 12:48
After the password is accepted an expired certificate infos are dumped on stdout and the last line is "Would you like to connect to this server? (Y/N)" ... Maybe it could be a problem the fact that the question contains many lines...
– Spike.WD
Feb 7 at 12:48
Is there a reason that you have an
interact
before your second expect
command? That interact doesn't have a return condition, so the expect ".*(Y/N)"
is never reached... Also: the /
character isn't special to regular expressions and doesn't need to be escaped, and the .*
at the beginning of the expect pattern is extraneous.– This isn't my real name
Feb 7 at 17:00
Is there a reason that you have an
interact
before your second expect
command? That interact doesn't have a return condition, so the expect ".*(Y/N)"
is never reached... Also: the /
character isn't special to regular expressions and doesn't need to be escaped, and the .*
at the beginning of the expect pattern is extraneous.– This isn't my real name
Feb 7 at 17:00
add a comment |
1 Answer
1
active
oldest
votes
Expect is doing exactly as you've told it to do.
You have the interact
command without an exit criteria, so at that point the script gives control to the user and never takes it back.
If you need interactive access in the middle of an Expect script, see this question in Stack Overflow.SE. There are multiple answers that might be applicable, depending on exactly how you wish the script to behave.
If the script is supposed to be fully automated with no user interaction after starting the script, then why is the interact
command there?
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499262%2fexpect-script-multiple-q-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Expect is doing exactly as you've told it to do.
You have the interact
command without an exit criteria, so at that point the script gives control to the user and never takes it back.
If you need interactive access in the middle of an Expect script, see this question in Stack Overflow.SE. There are multiple answers that might be applicable, depending on exactly how you wish the script to behave.
If the script is supposed to be fully automated with no user interaction after starting the script, then why is the interact
command there?
add a comment |
Expect is doing exactly as you've told it to do.
You have the interact
command without an exit criteria, so at that point the script gives control to the user and never takes it back.
If you need interactive access in the middle of an Expect script, see this question in Stack Overflow.SE. There are multiple answers that might be applicable, depending on exactly how you wish the script to behave.
If the script is supposed to be fully automated with no user interaction after starting the script, then why is the interact
command there?
add a comment |
Expect is doing exactly as you've told it to do.
You have the interact
command without an exit criteria, so at that point the script gives control to the user and never takes it back.
If you need interactive access in the middle of an Expect script, see this question in Stack Overflow.SE. There are multiple answers that might be applicable, depending on exactly how you wish the script to behave.
If the script is supposed to be fully automated with no user interaction after starting the script, then why is the interact
command there?
Expect is doing exactly as you've told it to do.
You have the interact
command without an exit criteria, so at that point the script gives control to the user and never takes it back.
If you need interactive access in the middle of an Expect script, see this question in Stack Overflow.SE. There are multiple answers that might be applicable, depending on exactly how you wish the script to behave.
If the script is supposed to be fully automated with no user interaction after starting the script, then why is the interact
command there?
answered Feb 7 at 13:30
telcoMtelcoM
17.4k12347
17.4k12347
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499262%2fexpect-script-multiple-q-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Error: “Would you like to connect to this server? (Y/N)” not found in script. I assume that it comes from an external command. Therefore you will have to give us some more information.
– ctrl-alt-delor
Feb 7 at 11:30
The question comes from /path/vpntool binary which the Forticlient SSL VPN client. The second question comes on stdout only after the first value(password) is accepted. And it it usually comes with an delay smaller than 1 sec . I've also tried with "Would you like to connect to this server? (Y/N)" instead of the regex, and still doesn't work...
– Spike.WD
Feb 7 at 11:59
I note you escaped the
/
. Is that the cause? OR maybe you need to sendYn
.– ctrl-alt-delor
Feb 7 at 12:05
After the password is accepted an expired certificate infos are dumped on stdout and the last line is "Would you like to connect to this server? (Y/N)" ... Maybe it could be a problem the fact that the question contains many lines...
– Spike.WD
Feb 7 at 12:48
Is there a reason that you have an
interact
before your secondexpect
command? That interact doesn't have a return condition, so theexpect ".*(Y/N)"
is never reached... Also: the/
character isn't special to regular expressions and doesn't need to be escaped, and the.*
at the beginning of the expect pattern is extraneous.– This isn't my real name
Feb 7 at 17:00