Unable to mput all the files through sftp in the remote server using expect












0















I'm trying to mput all files present in the directory : /Test/XML/ into a remote sftp server with the help of expect utility.



I've around 320 files in the directory: /Test/XML/.



The size of each file is around 0.1 MB.



There's no error observed.



Here's my code:



cd /Test/XML/

/usr/bin/expect <<EOF
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}r"
expect "sftp>"
send "cd /testr"
expect "sftp>"
send "mkdir XMLr"
expect "sftp>"
send "cd /test/XMLr"
expect "sftp>"
send "mput *r"
expect "sftp>"
send "byer"
EOF


But the problem here is, mput * is transferring only 4 files instead of transferring all the 320 files.
Not sure, why it's not able to transfer all the 320 files in the remote server.



Any help is most welcome.










share|improve this question

























  • did you get any error before exist the script ?? i mean connection aborted or something related to proxy ?

    – ntshetty
    Nov 15 '18 at 9:01













  • Did you check if you can turn off interactive prompting (PROMPT command)?

    – Mark Setchell
    Nov 15 '18 at 9:04











  • you can also try recursive by replacing mput with put -r * so that it will transfer files along with folder if any.

    – ntshetty
    Nov 15 '18 at 9:06











  • @ThiruShetty: I ran the script in debug mode.There's no error observed. I need to transfer files only.

    – A.K
    Nov 15 '18 at 9:16











  • all files with same extension ?? like .xml ?

    – ntshetty
    Nov 15 '18 at 9:19
















0















I'm trying to mput all files present in the directory : /Test/XML/ into a remote sftp server with the help of expect utility.



I've around 320 files in the directory: /Test/XML/.



The size of each file is around 0.1 MB.



There's no error observed.



Here's my code:



cd /Test/XML/

/usr/bin/expect <<EOF
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}r"
expect "sftp>"
send "cd /testr"
expect "sftp>"
send "mkdir XMLr"
expect "sftp>"
send "cd /test/XMLr"
expect "sftp>"
send "mput *r"
expect "sftp>"
send "byer"
EOF


But the problem here is, mput * is transferring only 4 files instead of transferring all the 320 files.
Not sure, why it's not able to transfer all the 320 files in the remote server.



Any help is most welcome.










share|improve this question

























  • did you get any error before exist the script ?? i mean connection aborted or something related to proxy ?

    – ntshetty
    Nov 15 '18 at 9:01













  • Did you check if you can turn off interactive prompting (PROMPT command)?

    – Mark Setchell
    Nov 15 '18 at 9:04











  • you can also try recursive by replacing mput with put -r * so that it will transfer files along with folder if any.

    – ntshetty
    Nov 15 '18 at 9:06











  • @ThiruShetty: I ran the script in debug mode.There's no error observed. I need to transfer files only.

    – A.K
    Nov 15 '18 at 9:16











  • all files with same extension ?? like .xml ?

    – ntshetty
    Nov 15 '18 at 9:19














0












0








0


1






I'm trying to mput all files present in the directory : /Test/XML/ into a remote sftp server with the help of expect utility.



I've around 320 files in the directory: /Test/XML/.



The size of each file is around 0.1 MB.



There's no error observed.



Here's my code:



cd /Test/XML/

/usr/bin/expect <<EOF
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}r"
expect "sftp>"
send "cd /testr"
expect "sftp>"
send "mkdir XMLr"
expect "sftp>"
send "cd /test/XMLr"
expect "sftp>"
send "mput *r"
expect "sftp>"
send "byer"
EOF


But the problem here is, mput * is transferring only 4 files instead of transferring all the 320 files.
Not sure, why it's not able to transfer all the 320 files in the remote server.



Any help is most welcome.










share|improve this question
















I'm trying to mput all files present in the directory : /Test/XML/ into a remote sftp server with the help of expect utility.



I've around 320 files in the directory: /Test/XML/.



The size of each file is around 0.1 MB.



There's no error observed.



Here's my code:



cd /Test/XML/

/usr/bin/expect <<EOF
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}r"
expect "sftp>"
send "cd /testr"
expect "sftp>"
send "mkdir XMLr"
expect "sftp>"
send "cd /test/XMLr"
expect "sftp>"
send "mput *r"
expect "sftp>"
send "byer"
EOF


But the problem here is, mput * is transferring only 4 files instead of transferring all the 320 files.
Not sure, why it's not able to transfer all the 320 files in the remote server.



Any help is most welcome.







linux bash sftp expect






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 9:55







A.K

















asked Nov 15 '18 at 7:09









A.KA.K

307




307













  • did you get any error before exist the script ?? i mean connection aborted or something related to proxy ?

    – ntshetty
    Nov 15 '18 at 9:01













  • Did you check if you can turn off interactive prompting (PROMPT command)?

    – Mark Setchell
    Nov 15 '18 at 9:04











  • you can also try recursive by replacing mput with put -r * so that it will transfer files along with folder if any.

    – ntshetty
    Nov 15 '18 at 9:06











  • @ThiruShetty: I ran the script in debug mode.There's no error observed. I need to transfer files only.

    – A.K
    Nov 15 '18 at 9:16











  • all files with same extension ?? like .xml ?

    – ntshetty
    Nov 15 '18 at 9:19



















  • did you get any error before exist the script ?? i mean connection aborted or something related to proxy ?

    – ntshetty
    Nov 15 '18 at 9:01













  • Did you check if you can turn off interactive prompting (PROMPT command)?

    – Mark Setchell
    Nov 15 '18 at 9:04











  • you can also try recursive by replacing mput with put -r * so that it will transfer files along with folder if any.

    – ntshetty
    Nov 15 '18 at 9:06











  • @ThiruShetty: I ran the script in debug mode.There's no error observed. I need to transfer files only.

    – A.K
    Nov 15 '18 at 9:16











  • all files with same extension ?? like .xml ?

    – ntshetty
    Nov 15 '18 at 9:19

















did you get any error before exist the script ?? i mean connection aborted or something related to proxy ?

– ntshetty
Nov 15 '18 at 9:01







did you get any error before exist the script ?? i mean connection aborted or something related to proxy ?

– ntshetty
Nov 15 '18 at 9:01















Did you check if you can turn off interactive prompting (PROMPT command)?

– Mark Setchell
Nov 15 '18 at 9:04





Did you check if you can turn off interactive prompting (PROMPT command)?

– Mark Setchell
Nov 15 '18 at 9:04













you can also try recursive by replacing mput with put -r * so that it will transfer files along with folder if any.

– ntshetty
Nov 15 '18 at 9:06





you can also try recursive by replacing mput with put -r * so that it will transfer files along with folder if any.

– ntshetty
Nov 15 '18 at 9:06













@ThiruShetty: I ran the script in debug mode.There's no error observed. I need to transfer files only.

– A.K
Nov 15 '18 at 9:16





@ThiruShetty: I ran the script in debug mode.There's no error observed. I need to transfer files only.

– A.K
Nov 15 '18 at 9:16













all files with same extension ?? like .xml ?

– ntshetty
Nov 15 '18 at 9:19





all files with same extension ?? like .xml ?

– ntshetty
Nov 15 '18 at 9:19












1 Answer
1






active

oldest

votes


















0














Thanks @ThiruShetty for the hint of using set timeout -1 in the expect utility.



Actually, i had a lot of files(~320-350) to be transferred(sftp) to a remote server.
With the normal execution of sftp using expect utility, it was able to transfer only a few files, not all of them which i wanted.



After inserting set timeout -1 inside expect, it solved the problem of timeout.



Here's the final code:



cd /Test/XML/

/usr/bin/expect <<EOF
set timeout -1
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}r"
expect "sftp>"
send "cd /testr"
expect "sftp>"
send "mkdir XMLr"
expect "sftp>"
send "cd /test/XMLr"
expect "sftp>"
send "mput *r"
expect "sftp>"
send "byer"
EOF





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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%2fstackoverflow.com%2fquestions%2f53314126%2funable-to-mput-all-the-files-through-sftp-in-the-remote-server-using-expect%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














    Thanks @ThiruShetty for the hint of using set timeout -1 in the expect utility.



    Actually, i had a lot of files(~320-350) to be transferred(sftp) to a remote server.
    With the normal execution of sftp using expect utility, it was able to transfer only a few files, not all of them which i wanted.



    After inserting set timeout -1 inside expect, it solved the problem of timeout.



    Here's the final code:



    cd /Test/XML/

    /usr/bin/expect <<EOF
    set timeout -1
    spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
    expect "password:"
    send "${passwd}r"
    expect "sftp>"
    send "cd /testr"
    expect "sftp>"
    send "mkdir XMLr"
    expect "sftp>"
    send "cd /test/XMLr"
    expect "sftp>"
    send "mput *r"
    expect "sftp>"
    send "byer"
    EOF





    share|improve this answer




























      0














      Thanks @ThiruShetty for the hint of using set timeout -1 in the expect utility.



      Actually, i had a lot of files(~320-350) to be transferred(sftp) to a remote server.
      With the normal execution of sftp using expect utility, it was able to transfer only a few files, not all of them which i wanted.



      After inserting set timeout -1 inside expect, it solved the problem of timeout.



      Here's the final code:



      cd /Test/XML/

      /usr/bin/expect <<EOF
      set timeout -1
      spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
      expect "password:"
      send "${passwd}r"
      expect "sftp>"
      send "cd /testr"
      expect "sftp>"
      send "mkdir XMLr"
      expect "sftp>"
      send "cd /test/XMLr"
      expect "sftp>"
      send "mput *r"
      expect "sftp>"
      send "byer"
      EOF





      share|improve this answer


























        0












        0








        0







        Thanks @ThiruShetty for the hint of using set timeout -1 in the expect utility.



        Actually, i had a lot of files(~320-350) to be transferred(sftp) to a remote server.
        With the normal execution of sftp using expect utility, it was able to transfer only a few files, not all of them which i wanted.



        After inserting set timeout -1 inside expect, it solved the problem of timeout.



        Here's the final code:



        cd /Test/XML/

        /usr/bin/expect <<EOF
        set timeout -1
        spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
        expect "password:"
        send "${passwd}r"
        expect "sftp>"
        send "cd /testr"
        expect "sftp>"
        send "mkdir XMLr"
        expect "sftp>"
        send "cd /test/XMLr"
        expect "sftp>"
        send "mput *r"
        expect "sftp>"
        send "byer"
        EOF





        share|improve this answer













        Thanks @ThiruShetty for the hint of using set timeout -1 in the expect utility.



        Actually, i had a lot of files(~320-350) to be transferred(sftp) to a remote server.
        With the normal execution of sftp using expect utility, it was able to transfer only a few files, not all of them which i wanted.



        After inserting set timeout -1 inside expect, it solved the problem of timeout.



        Here's the final code:



        cd /Test/XML/

        /usr/bin/expect <<EOF
        set timeout -1
        spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
        expect "password:"
        send "${passwd}r"
        expect "sftp>"
        send "cd /testr"
        expect "sftp>"
        send "mkdir XMLr"
        expect "sftp>"
        send "cd /test/XMLr"
        expect "sftp>"
        send "mput *r"
        expect "sftp>"
        send "byer"
        EOF






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 15:38









        A.KA.K

        307




        307
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f53314126%2funable-to-mput-all-the-files-through-sftp-in-the-remote-server-using-expect%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

            Florida Star v. B. J. F.

            Error while running script in elastic search , gateway timeout

            Adding quotations to stringified JSON object values