Batch file or script to telnet to multiple hosts, log initial output then close and test next host





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have a large list of IP addresses from a database that I need to sanitize and determine which type of host (it'll be one of 2 device types) each IP address relates to.



Is there a way of using a batch file and/or Putty to telnet to (but not necessarily log in to) each host, check the initial message from the host, log it to a file and then disconnect and test the next one and so on?










share|improve this question























  • What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

    – DavidPostill
    Jun 23 '15 at 12:19











  • Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code.

    – Faldinio
    Jun 23 '15 at 13:04











  • I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G

    – JosefZ
    Jun 23 '15 at 22:24


















0















I have a large list of IP addresses from a database that I need to sanitize and determine which type of host (it'll be one of 2 device types) each IP address relates to.



Is there a way of using a batch file and/or Putty to telnet to (but not necessarily log in to) each host, check the initial message from the host, log it to a file and then disconnect and test the next one and so on?










share|improve this question























  • What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

    – DavidPostill
    Jun 23 '15 at 12:19











  • Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code.

    – Faldinio
    Jun 23 '15 at 13:04











  • I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G

    – JosefZ
    Jun 23 '15 at 22:24














0












0








0








I have a large list of IP addresses from a database that I need to sanitize and determine which type of host (it'll be one of 2 device types) each IP address relates to.



Is there a way of using a batch file and/or Putty to telnet to (but not necessarily log in to) each host, check the initial message from the host, log it to a file and then disconnect and test the next one and so on?










share|improve this question














I have a large list of IP addresses from a database that I need to sanitize and determine which type of host (it'll be one of 2 device types) each IP address relates to.



Is there a way of using a batch file and/or Putty to telnet to (but not necessarily log in to) each host, check the initial message from the host, log it to a file and then disconnect and test the next one and so on?







batch batch-file putty telnet






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 23 '15 at 12:14









FaldinioFaldinio

612




612













  • What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

    – DavidPostill
    Jun 23 '15 at 12:19











  • Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code.

    – Faldinio
    Jun 23 '15 at 13:04











  • I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G

    – JosefZ
    Jun 23 '15 at 22:24



















  • What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

    – DavidPostill
    Jun 23 '15 at 12:19











  • Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code.

    – Faldinio
    Jun 23 '15 at 13:04











  • I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G

    – JosefZ
    Jun 23 '15 at 22:24

















What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

– DavidPostill
Jun 23 '15 at 12:19





What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

– DavidPostill
Jun 23 '15 at 12:19













Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code.

– Faldinio
Jun 23 '15 at 13:04





Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code.

– Faldinio
Jun 23 '15 at 13:04













I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G

– JosefZ
Jun 23 '15 at 22:24





I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G

– JosefZ
Jun 23 '15 at 22:24










1 Answer
1






active

oldest

votes


















0














You can look in to using expect. It should suit your needs. There are a few questions/posts on here about it.






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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%2fsuperuser.com%2fquestions%2f931473%2fbatch-file-or-script-to-telnet-to-multiple-hosts-log-initial-output-then-close%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









    0














    You can look in to using expect. It should suit your needs. There are a few questions/posts on here about it.






    share|improve this answer






























      0














      You can look in to using expect. It should suit your needs. There are a few questions/posts on here about it.






      share|improve this answer




























        0












        0








        0







        You can look in to using expect. It should suit your needs. There are a few questions/posts on here about it.






        share|improve this answer















        You can look in to using expect. It should suit your needs. There are a few questions/posts on here about it.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 20 '17 at 10:17









        Community

        1




        1










        answered Nov 21 '16 at 15:29









        daveluptdavelupt

        179110




        179110






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • 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%2fsuperuser.com%2fquestions%2f931473%2fbatch-file-or-script-to-telnet-to-multiple-hosts-log-initial-output-then-close%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

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...