'expect' not matching server response stringMake a shell script execute commands in telnet or programsHuge...
Unsolved Problems due to Lack of Computational Power
Quick destruction of a helium filled airship?
Is it alright to say good afternoon Sirs and Madams in a panel interview?
Why is su world executable?
Heyawacky: Ace of Cups
My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?
Gofer work in exchange for Letter of Recommendation
How do the Durable and Dwarven Fortitude feats interact?
Is this bar slide trick shown on Cheers real or a visual effect?
Existence of a certain set of 0/1-sequences without the Axiom of Choice
C++ Least cost swapping 2
Why is the battery jumpered to a resistor in this schematic?
Radix2 Fast Fourier Transform implemented in C++
Why do aircraft leave cruising altitude long before landing just to circle?
Are there any rules on how characters go from 0th to 1st level in a class?
Why does this image of cyclocarbon look like a nonagon?
What does a comma signify in inorganic chemistry?
What exactly happened to the 18 crew members who were reported as "missing" in "Q Who"?
Earliest evidence of objects intended for future archaeologists?
How does the illumination of the sky from the sun compare to that of the moon?
Subgroup generated by a subgroup and a conjugate of it
Are there any OR challenges that are similar to kaggle's competitions?
A reccomended structured approach to self studying music theory for songwriting
Number of matrices with bounded products of rows and columns
'expect' not matching server response string
Make a shell script execute commands in telnet or programsHuge delay in script response when using SFTP with expectlogin to remote server using expect programexpect script not working in for loopRun a local expect script on a remote server?Working with expect commandExpect, Command, Pipes and Gzipinteractive SMTP command using telnet via a shell script
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm using a bash script to log into a telnet server and execute a number of commands. It looks like:
login_and_run.sh
#!/bin/bash
unset TELNET_USER_NAME_STRING
unset TELNET_PASSWORD_STRING
unset TELNET_USER_NAME
unset TELNET_PASSWORD
TELNET_USER_NAME_STRING=`cat SAP_output`
TELNET_PASSWORD_STRING="Password:"
TELNET_USER_NAME="UserNam3r"
TELNET_PASSWORD="Passw0rdr"
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
sleep 3
expect "$TELNET_PASSWORD_STRING"
send "$TELNET_PASSWORD"
sleep 3
spawn ls
expect eof
DONE
where
SAP_output:
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
***********************************************
**********************************************
****###*******####*****#######**************
**##***##****##**##****##****##************
***##*******##****##***##****##**********
*****##*****########***######***********
******##****##****##***##*************
**##***##**##******##**##************
****###****##******##**##**********
**********************************
********************************
Telnet Administration
SAP Java EE Application Server v7.50
User name:
telnet logs in, I get the banner, but it stops there (as if the strings are not matching). Would it be safer to use wildcards instead of the exact response (and match only " User name: ")?
shell-script login expect pattern-matching
add a comment |
I'm using a bash script to log into a telnet server and execute a number of commands. It looks like:
login_and_run.sh
#!/bin/bash
unset TELNET_USER_NAME_STRING
unset TELNET_PASSWORD_STRING
unset TELNET_USER_NAME
unset TELNET_PASSWORD
TELNET_USER_NAME_STRING=`cat SAP_output`
TELNET_PASSWORD_STRING="Password:"
TELNET_USER_NAME="UserNam3r"
TELNET_PASSWORD="Passw0rdr"
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
sleep 3
expect "$TELNET_PASSWORD_STRING"
send "$TELNET_PASSWORD"
sleep 3
spawn ls
expect eof
DONE
where
SAP_output:
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
***********************************************
**********************************************
****###*******####*****#######**************
**##***##****##**##****##****##************
***##*******##****##***##****##**********
*****##*****########***######***********
******##****##****##***##*************
**##***##**##******##**##************
****###****##******##**##**********
**********************************
********************************
Telnet Administration
SAP Java EE Application Server v7.50
User name:
telnet logs in, I get the banner, but it stops there (as if the strings are not matching). Would it be safer to use wildcards instead of the exact response (and match only " User name: ")?
shell-script login expect pattern-matching
1
Note that single quotes have no special meaning in expect/tcl. You are expecting to see literal single quotes.
– glenn jackman
yesterday
1
Also, expect usesrn
for newlines, and that file, I'm guessing, does not contain carriage returns.
– glenn jackman
yesterday
1
When composing an expect program, turn on verbose debugging withexp_internal 1
-- that will show you when your patterns are not matching.
– glenn jackman
yesterday
add a comment |
I'm using a bash script to log into a telnet server and execute a number of commands. It looks like:
login_and_run.sh
#!/bin/bash
unset TELNET_USER_NAME_STRING
unset TELNET_PASSWORD_STRING
unset TELNET_USER_NAME
unset TELNET_PASSWORD
TELNET_USER_NAME_STRING=`cat SAP_output`
TELNET_PASSWORD_STRING="Password:"
TELNET_USER_NAME="UserNam3r"
TELNET_PASSWORD="Passw0rdr"
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
sleep 3
expect "$TELNET_PASSWORD_STRING"
send "$TELNET_PASSWORD"
sleep 3
spawn ls
expect eof
DONE
where
SAP_output:
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
***********************************************
**********************************************
****###*******####*****#######**************
**##***##****##**##****##****##************
***##*******##****##***##****##**********
*****##*****########***######***********
******##****##****##***##*************
**##***##**##******##**##************
****###****##******##**##**********
**********************************
********************************
Telnet Administration
SAP Java EE Application Server v7.50
User name:
telnet logs in, I get the banner, but it stops there (as if the strings are not matching). Would it be safer to use wildcards instead of the exact response (and match only " User name: ")?
shell-script login expect pattern-matching
I'm using a bash script to log into a telnet server and execute a number of commands. It looks like:
login_and_run.sh
#!/bin/bash
unset TELNET_USER_NAME_STRING
unset TELNET_PASSWORD_STRING
unset TELNET_USER_NAME
unset TELNET_PASSWORD
TELNET_USER_NAME_STRING=`cat SAP_output`
TELNET_PASSWORD_STRING="Password:"
TELNET_USER_NAME="UserNam3r"
TELNET_PASSWORD="Passw0rdr"
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
sleep 3
expect "$TELNET_PASSWORD_STRING"
send "$TELNET_PASSWORD"
sleep 3
spawn ls
expect eof
DONE
where
SAP_output:
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
***********************************************
**********************************************
****###*******####*****#######**************
**##***##****##**##****##****##************
***##*******##****##***##****##**********
*****##*****########***######***********
******##****##****##***##*************
**##***##**##******##**##************
****###****##******##**##**********
**********************************
********************************
Telnet Administration
SAP Java EE Application Server v7.50
User name:
telnet logs in, I get the banner, but it stops there (as if the strings are not matching). Would it be safer to use wildcards instead of the exact response (and match only " User name: ")?
shell-script login expect pattern-matching
shell-script login expect pattern-matching
edited 2 days ago
Sebi
asked 2 days ago
SebiSebi
4281 gold badge10 silver badges25 bronze badges
4281 gold badge10 silver badges25 bronze badges
1
Note that single quotes have no special meaning in expect/tcl. You are expecting to see literal single quotes.
– glenn jackman
yesterday
1
Also, expect usesrn
for newlines, and that file, I'm guessing, does not contain carriage returns.
– glenn jackman
yesterday
1
When composing an expect program, turn on verbose debugging withexp_internal 1
-- that will show you when your patterns are not matching.
– glenn jackman
yesterday
add a comment |
1
Note that single quotes have no special meaning in expect/tcl. You are expecting to see literal single quotes.
– glenn jackman
yesterday
1
Also, expect usesrn
for newlines, and that file, I'm guessing, does not contain carriage returns.
– glenn jackman
yesterday
1
When composing an expect program, turn on verbose debugging withexp_internal 1
-- that will show you when your patterns are not matching.
– glenn jackman
yesterday
1
1
Note that single quotes have no special meaning in expect/tcl. You are expecting to see literal single quotes.
– glenn jackman
yesterday
Note that single quotes have no special meaning in expect/tcl. You are expecting to see literal single quotes.
– glenn jackman
yesterday
1
1
Also, expect uses
rn
for newlines, and that file, I'm guessing, does not contain carriage returns.– glenn jackman
yesterday
Also, expect uses
rn
for newlines, and that file, I'm guessing, does not contain carriage returns.– glenn jackman
yesterday
1
1
When composing an expect program, turn on verbose debugging with
exp_internal 1
-- that will show you when your patterns are not matching.– glenn jackman
yesterday
When composing an expect program, turn on verbose debugging with
exp_internal 1
-- that will show you when your patterns are not matching.– glenn jackman
yesterday
add a comment |
1 Answer
1
active
oldest
votes
Figured it out:
TELNET_USER_NAME_STRING='*name:*'
TELNET_PASSWORD_STRING='*assword:*'
TELNET_USER_NAME='UserNam3r'
TELNET_PASSWORD='Passw0rdr'
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
expect '$TELNET_PASSWORD_STRING'
send "$TELNET_PASSWORD"
# Check if we're logged in
expect eof
DONE
Use wildcards instead of the full banner and return line character 'r' to 'press' enter.
Edit:
This is a far more elegant answer.
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%2f535750%2fexpect-not-matching-server-response-string%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
Figured it out:
TELNET_USER_NAME_STRING='*name:*'
TELNET_PASSWORD_STRING='*assword:*'
TELNET_USER_NAME='UserNam3r'
TELNET_PASSWORD='Passw0rdr'
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
expect '$TELNET_PASSWORD_STRING'
send "$TELNET_PASSWORD"
# Check if we're logged in
expect eof
DONE
Use wildcards instead of the full banner and return line character 'r' to 'press' enter.
Edit:
This is a far more elegant answer.
add a comment |
Figured it out:
TELNET_USER_NAME_STRING='*name:*'
TELNET_PASSWORD_STRING='*assword:*'
TELNET_USER_NAME='UserNam3r'
TELNET_PASSWORD='Passw0rdr'
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
expect '$TELNET_PASSWORD_STRING'
send "$TELNET_PASSWORD"
# Check if we're logged in
expect eof
DONE
Use wildcards instead of the full banner and return line character 'r' to 'press' enter.
Edit:
This is a far more elegant answer.
add a comment |
Figured it out:
TELNET_USER_NAME_STRING='*name:*'
TELNET_PASSWORD_STRING='*assword:*'
TELNET_USER_NAME='UserNam3r'
TELNET_PASSWORD='Passw0rdr'
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
expect '$TELNET_PASSWORD_STRING'
send "$TELNET_PASSWORD"
# Check if we're logged in
expect eof
DONE
Use wildcards instead of the full banner and return line character 'r' to 'press' enter.
Edit:
This is a far more elegant answer.
Figured it out:
TELNET_USER_NAME_STRING='*name:*'
TELNET_PASSWORD_STRING='*assword:*'
TELNET_USER_NAME='UserNam3r'
TELNET_PASSWORD='Passw0rdr'
# Expect script starts here
expect <<- DONE
spawn telnet localhost 50008
expect '$TELNET_USER_NAME_STRING'
send "$TELNET_USER_NAME"
expect '$TELNET_PASSWORD_STRING'
send "$TELNET_PASSWORD"
# Check if we're logged in
expect eof
DONE
Use wildcards instead of the full banner and return line character 'r' to 'press' enter.
Edit:
This is a far more elegant answer.
edited 2 days ago
answered 2 days ago
SebiSebi
4281 gold badge10 silver badges25 bronze badges
4281 gold badge10 silver badges25 bronze badges
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%2f535750%2fexpect-not-matching-server-response-string%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
1
Note that single quotes have no special meaning in expect/tcl. You are expecting to see literal single quotes.
– glenn jackman
yesterday
1
Also, expect uses
rn
for newlines, and that file, I'm guessing, does not contain carriage returns.– glenn jackman
yesterday
1
When composing an expect program, turn on verbose debugging with
exp_internal 1
-- that will show you when your patterns are not matching.– glenn jackman
yesterday