Unable to send password and username












0















Unable to send root and password after telnet. Why?



telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"









share|improve this question




















  • 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


















0















Unable to send root and password after telnet. Why?



telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"









share|improve this question




















  • 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
















0












0








0








Unable to send root and password after telnet. Why?



telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"









share|improve this question
















Unable to send root and password after telnet. Why?



telnet board
sleep 3
echo -e "rootn"
sleep 1
echo -e "labratn"






login






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 7 at 13:53









PerlDuck

5,86211333




5,86211333










asked Jan 7 at 13:52









HenryZHenryZ

1




1








  • 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
















  • 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










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












2 Answers
2






active

oldest

votes


















4














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.






share|improve this answer





















  • 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
    Jan 8 at 8:12



















0














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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    4














    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.






    share|improve this answer





















    • 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
      Jan 8 at 8:12
















    4














    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.






    share|improve this answer





















    • 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
      Jan 8 at 8:12














    4












    4








    4







    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.






    share|improve this answer















    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 8 at 8:16

























    answered Jan 7 at 14:47









    Mr ShunzMr Shunz

    2,39521922




    2,39521922








    • 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
      Jan 8 at 8:12














    • 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
      Jan 8 at 8:12








    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
    Jan 8 at 8:12





    @Melebius you're right. Never used expect to leave an interactive prompt. Editing my question right now.

    – Mr Shunz
    Jan 8 at 8:12













    0














    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.






    share|improve this answer




























      0














      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.






      share|improve this answer


























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 7 at 14:26









        wjandreawjandrea

        8,52142260




        8,52142260






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Ellipse (mathématiques)

            Quarter-circle Tiles

            Mont Emei