Unable to send password and username
Unable to send root and password after telnet. Why?
telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"
login
New contributor
add a comment |
Unable to send root and password after telnet. Why?
telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"
login
New contributor
2
Related: stackoverflow.com/questions/7013137/…, stackoverflow.com/questions/12202587/…
– Melebius
Jan 7 at 13:57
1
You... do know that the way shell script commands are utilized it won't really do anything untiltelnet
exits, right? So therefore it's not going to dump your messages into the telnet session properly? Or are you using some other script mechanisms here?
– Thomas Ward♦
Jan 7 at 14:33
add a comment |
Unable to send root and password after telnet. Why?
telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"
login
New contributor
Unable to send root and password after telnet. Why?
telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"
login
login
New contributor
New contributor
edited Jan 7 at 13:53
PerlDuck
5,52411231
5,52411231
New contributor
asked Jan 7 at 13:52
HenryZHenryZ
1
1
New contributor
New contributor
2
Related: stackoverflow.com/questions/7013137/…, stackoverflow.com/questions/12202587/…
– Melebius
Jan 7 at 13:57
1
You... do know that the way shell script commands are utilized it won't really do anything untiltelnet
exits, right? So therefore it's not going to dump your messages into the telnet session properly? Or are you using some other script mechanisms here?
– Thomas Ward♦
Jan 7 at 14:33
add a comment |
2
Related: stackoverflow.com/questions/7013137/…, stackoverflow.com/questions/12202587/…
– Melebius
Jan 7 at 13:57
1
You... do know that the way shell script commands are utilized it won't really do anything untiltelnet
exits, right? So therefore it's not going to dump your messages into the telnet session properly? Or are you using some other script mechanisms here?
– Thomas Ward♦
Jan 7 at 14:33
2
2
Related: stackoverflow.com/questions/7013137/…, stackoverflow.com/questions/12202587/…
– Melebius
Jan 7 at 13:57
Related: stackoverflow.com/questions/7013137/…, stackoverflow.com/questions/12202587/…
– Melebius
Jan 7 at 13:57
1
1
You... do know that the way shell script commands are utilized it won't really do anything until
telnet
exits, right? So therefore it's not going to dump your messages into the telnet session properly? Or are you using some other script mechanisms here?– Thomas Ward♦
Jan 7 at 14:33
You... do know that the way shell script commands are utilized it won't really do anything until
telnet
exits, right? So therefore it's not going to dump your messages into the telnet session properly? Or are you using some other script mechanisms here?– Thomas Ward♦
Jan 7 at 14:33
add a comment |
2 Answers
2
active
oldest
votes
You cannot use a "simple" bash script to interact with a telnet
session.
As per @Melebius comment, the answers to this question on StackOverflow propose some solutions, like using expect. As a simpler alternative you can pipe your commands to telnet
:
{ sleep 3 ; echo "root" ; sleep 1 ; echo "labrat" ; sleep 1; } | telnet board
Please keep in mind that this way the telnet session terminates soon after the input is processed. If you want to create an automated script, it might be enough (but then expect
is still a better way).
EDIT as per comments
If instead you want to open an interactive telnet
session, but save yourself the "hassle" of entering username and password every time, I'm afraid there's not a simple solution. You can pass the username via the -l
flag (i.e. telnet -l root board
) so
you need to enter only the password.
Looks like expect
can be used successfully to automate telnet logins while leaving an interactive prompt via the interact
directive.
A simple example based would be:
#!/usr/bin/expect
spawn telnet board
sleep .3;
expect "login:"
send "rootr"
expect "password:"
send "labratr";
interact
Just edit to your needs.
1
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
add a comment |
I'm not sure if this is the cause of the issue (never used telnet myself), but echo
already adds a newline when printing, so echo -e "rootn"
will print root
then two newlines. You probably want just one, so use echo "root"
or printf 'rootn'
instead.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});
}
});
HenryZ is a new contributor. Be nice, and check out our Code of Conduct.
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%2faskubuntu.com%2fquestions%2f1107722%2funable-to-send-password-and-username%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You cannot use a "simple" bash script to interact with a telnet
session.
As per @Melebius comment, the answers to this question on StackOverflow propose some solutions, like using expect. As a simpler alternative you can pipe your commands to telnet
:
{ sleep 3 ; echo "root" ; sleep 1 ; echo "labrat" ; sleep 1; } | telnet board
Please keep in mind that this way the telnet session terminates soon after the input is processed. If you want to create an automated script, it might be enough (but then expect
is still a better way).
EDIT as per comments
If instead you want to open an interactive telnet
session, but save yourself the "hassle" of entering username and password every time, I'm afraid there's not a simple solution. You can pass the username via the -l
flag (i.e. telnet -l root board
) so
you need to enter only the password.
Looks like expect
can be used successfully to automate telnet logins while leaving an interactive prompt via the interact
directive.
A simple example based would be:
#!/usr/bin/expect
spawn telnet board
sleep .3;
expect "login:"
send "rootr"
expect "password:"
send "labratr";
interact
Just edit to your needs.
1
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
add a comment |
You cannot use a "simple" bash script to interact with a telnet
session.
As per @Melebius comment, the answers to this question on StackOverflow propose some solutions, like using expect. As a simpler alternative you can pipe your commands to telnet
:
{ sleep 3 ; echo "root" ; sleep 1 ; echo "labrat" ; sleep 1; } | telnet board
Please keep in mind that this way the telnet session terminates soon after the input is processed. If you want to create an automated script, it might be enough (but then expect
is still a better way).
EDIT as per comments
If instead you want to open an interactive telnet
session, but save yourself the "hassle" of entering username and password every time, I'm afraid there's not a simple solution. You can pass the username via the -l
flag (i.e. telnet -l root board
) so
you need to enter only the password.
Looks like expect
can be used successfully to automate telnet logins while leaving an interactive prompt via the interact
directive.
A simple example based would be:
#!/usr/bin/expect
spawn telnet board
sleep .3;
expect "login:"
send "rootr"
expect "password:"
send "labratr";
interact
Just edit to your needs.
1
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
add a comment |
You cannot use a "simple" bash script to interact with a telnet
session.
As per @Melebius comment, the answers to this question on StackOverflow propose some solutions, like using expect. As a simpler alternative you can pipe your commands to telnet
:
{ sleep 3 ; echo "root" ; sleep 1 ; echo "labrat" ; sleep 1; } | telnet board
Please keep in mind that this way the telnet session terminates soon after the input is processed. If you want to create an automated script, it might be enough (but then expect
is still a better way).
EDIT as per comments
If instead you want to open an interactive telnet
session, but save yourself the "hassle" of entering username and password every time, I'm afraid there's not a simple solution. You can pass the username via the -l
flag (i.e. telnet -l root board
) so
you need to enter only the password.
Looks like expect
can be used successfully to automate telnet logins while leaving an interactive prompt via the interact
directive.
A simple example based would be:
#!/usr/bin/expect
spawn telnet board
sleep .3;
expect "login:"
send "rootr"
expect "password:"
send "labratr";
interact
Just edit to your needs.
You cannot use a "simple" bash script to interact with a telnet
session.
As per @Melebius comment, the answers to this question on StackOverflow propose some solutions, like using expect. As a simpler alternative you can pipe your commands to telnet
:
{ sleep 3 ; echo "root" ; sleep 1 ; echo "labrat" ; sleep 1; } | telnet board
Please keep in mind that this way the telnet session terminates soon after the input is processed. If you want to create an automated script, it might be enough (but then expect
is still a better way).
EDIT as per comments
If instead you want to open an interactive telnet
session, but save yourself the "hassle" of entering username and password every time, I'm afraid there's not a simple solution. You can pass the username via the -l
flag (i.e. telnet -l root board
) so
you need to enter only the password.
Looks like expect
can be used successfully to automate telnet logins while leaving an interactive prompt via the interact
directive.
A simple example based would be:
#!/usr/bin/expect
spawn telnet board
sleep .3;
expect "login:"
send "rootr"
expect "password:"
send "labratr";
interact
Just edit to your needs.
edited 2 days ago
answered Jan 7 at 14:47
Mr ShunzMr Shunz
2,24521922
2,24521922
1
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
add a comment |
1
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
1
1
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
“If instead you want to open an interactive telnet session” Expect seems to be able to work here, too. There are more examples of using SSH (e.g. journaldev.com/1405/expect-script-ssh-example-tutorial) but it should work similarly with Telnet.
– Melebius
Jan 8 at 6:50
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
@Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.
– Mr Shunz
2 days ago
add a comment |
I'm not sure if this is the cause of the issue (never used telnet myself), but echo
already adds a newline when printing, so echo -e "rootn"
will print root
then two newlines. You probably want just one, so use echo "root"
or printf 'rootn'
instead.
add a comment |
I'm not sure if this is the cause of the issue (never used telnet myself), but echo
already adds a newline when printing, so echo -e "rootn"
will print root
then two newlines. You probably want just one, so use echo "root"
or printf 'rootn'
instead.
add a comment |
I'm not sure if this is the cause of the issue (never used telnet myself), but echo
already adds a newline when printing, so echo -e "rootn"
will print root
then two newlines. You probably want just one, so use echo "root"
or printf 'rootn'
instead.
I'm not sure if this is the cause of the issue (never used telnet myself), but echo
already adds a newline when printing, so echo -e "rootn"
will print root
then two newlines. You probably want just one, so use echo "root"
or printf 'rootn'
instead.
answered Jan 7 at 14:26
wjandreawjandrea
8,47742259
8,47742259
add a comment |
add a comment |
HenryZ is a new contributor. Be nice, and check out our Code of Conduct.
HenryZ is a new contributor. Be nice, and check out our Code of Conduct.
HenryZ is a new contributor. Be nice, and check out our Code of Conduct.
HenryZ is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1107722%2funable-to-send-password-and-username%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
2
Related: stackoverflow.com/questions/7013137/…, stackoverflow.com/questions/12202587/…
– Melebius
Jan 7 at 13:57
1
You... do know that the way shell script commands are utilized it won't really do anything until
telnet
exits, right? So therefore it's not going to dump your messages into the telnet session properly? Or are you using some other script mechanisms here?– Thomas Ward♦
Jan 7 at 14:33