Log the output of Expect commandecho string >> file does not workExpect can not expect the outputsFTP...

How to reply this mail from potential PhD professor?

Was there ever a Kickstart that took advantage of 68020+ instructions that would work on an A2000?

I may be a fraud

Identifying a transmission to myself

What happens to the Time Stone

Type-check an expression

Can I get a paladin's steed by True Polymorphing into a monster that can cast Find Steed?

Which industry am I working in? Software development or financial services?

Moving the subject of the sentence into a dangling participle

Why is Arya visibly scared in the library in S8E3?

A non-technological, repeating, phenomenon in the sky, holding its position in the sky for hours

Catholic vs Protestant Support for Nazism in Germany

What does this colon mean? It is not labeling, it is not ternary operator

60s (or earlier) SF short story with FTL Travel using electron psychology aka addiclenendar technology

Reconstruct a matrix from its traces

What happens to matryoshka Mordenkainen's Magnificent Mansions?

What is the unit of the area when geometry attributes are calculated in QGIS?

Is Cola "probably the best-known" Latin word in the world? If not, which might it be?

SQL Server Management Studio SSMS 18.0 General Availability release (GA) install fails

In Endgame, why were these characters still around?

In Avengers 1, why does Thanos need Loki?

Missed the connecting flight, separate tickets on same airline - who is responsible?

What is the most remote airport from the center of the city it supposedly serves?

How can I get a job without pushing my family's income into a higher tax bracket?



Log the output of Expect command


echo string >> file does not workExpect can not expect the outputsFTP server fails to startWhy the output is not written to log from expect scriptCapture stdout from ssh session to local machineExpect script seems to ignore prompt (RSA fingerprint confirmation)Expect script to automatically log in, command and show its outputExpect script to ssh into a remote host and change its passwordExpect output useHow to output multi-page output in expect to file without option prompts being logged






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















I have made the below expect script and I need to log the output of that script.



SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' `
if [ -n "${SOURCE_FILE}" ]
then
cp -p ${SOURCE_FILE} ${T_FILES}
/usr/bin/expect<<EOD

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD
else
echo "No Files to copy" >> ${LOGFILE}
fi


I need to log the output of expect command in ${LOGFILE}. How can It be done?



I have tried adding the below things, it doesn't work. What could be done?



/usr/bin/expect<<EOD >> ${LOGFILE} 2>&1

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD









share|improve this question
















bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 3





    Use of backticks is deprecated use $(…) instead.

    – ctrl-alt-delor
    Jul 11 '16 at 8:46


















3















I have made the below expect script and I need to log the output of that script.



SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' `
if [ -n "${SOURCE_FILE}" ]
then
cp -p ${SOURCE_FILE} ${T_FILES}
/usr/bin/expect<<EOD

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD
else
echo "No Files to copy" >> ${LOGFILE}
fi


I need to log the output of expect command in ${LOGFILE}. How can It be done?



I have tried adding the below things, it doesn't work. What could be done?



/usr/bin/expect<<EOD >> ${LOGFILE} 2>&1

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD









share|improve this question
















bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 3





    Use of backticks is deprecated use $(…) instead.

    – ctrl-alt-delor
    Jul 11 '16 at 8:46














3












3








3


1






I have made the below expect script and I need to log the output of that script.



SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' `
if [ -n "${SOURCE_FILE}" ]
then
cp -p ${SOURCE_FILE} ${T_FILES}
/usr/bin/expect<<EOD

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD
else
echo "No Files to copy" >> ${LOGFILE}
fi


I need to log the output of expect command in ${LOGFILE}. How can It be done?



I have tried adding the below things, it doesn't work. What could be done?



/usr/bin/expect<<EOD >> ${LOGFILE} 2>&1

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD









share|improve this question
















I have made the below expect script and I need to log the output of that script.



SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' `
if [ -n "${SOURCE_FILE}" ]
then
cp -p ${SOURCE_FILE} ${T_FILES}
/usr/bin/expect<<EOD

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD
else
echo "No Files to copy" >> ${LOGFILE}
fi


I need to log the output of expect command in ${LOGFILE}. How can It be done?



I have tried adding the below things, it doesn't work. What could be done?



/usr/bin/expect<<EOD >> ${LOGFILE} 2>&1

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD






logs io-redirection sftp expect






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 30 '17 at 13:42









Kusalananda

144k18272450




144k18272450










asked Jul 11 '16 at 5:59









sabarish jacksonsabarish jackson

159412




159412





bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 3





    Use of backticks is deprecated use $(…) instead.

    – ctrl-alt-delor
    Jul 11 '16 at 8:46














  • 3





    Use of backticks is deprecated use $(…) instead.

    – ctrl-alt-delor
    Jul 11 '16 at 8:46








3




3





Use of backticks is deprecated use $(…) instead.

– ctrl-alt-delor
Jul 11 '16 at 8:46





Use of backticks is deprecated use $(…) instead.

– ctrl-alt-delor
Jul 11 '16 at 8:46










2 Answers
2






active

oldest

votes


















0














It looks like LOGFILE is out of scope, did you export it. See environment variables.



You need to export a variable to the environment, or pass it as an argument.



e.g.
Let us say your program is called abc then do:



LOGFILE=./logdir/logfile
export LOGFILE
./abc


or



LOGFILE=./logdir/logfile ./abc


Alternatively, pass as argument:



./abc "./logdir/logfile"


And have in program:



logfilename="$1"





share|improve this answer
























  • YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

    – sabarish jackson
    Jul 11 '16 at 9:19











  • @sabarishjackson That logfile name ends in / so is a directory not a file.

    – meuh
    Jul 11 '16 at 10:23











  • Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

    – ctrl-alt-delor
    Jul 11 '16 at 11:58











  • @meuh I gave it as a sample. I had the path to the file_name.txt

    – sabarish jackson
    Jul 12 '16 at 5:40



















0














The below mentioned redirection is working fine now. I didn't add anything new.



/usr/bin/expect<<EOD > ${LOGFILE}

set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST:$R_LOCATION
expect "*?assword:"
send "$passwordr"
expect "sftp>"
send "put /opt/AppServer/ES_billing_report/todays_report/*.txtr"
expect "sftp>"
send "byer"
expect EOD
EOD





share|improve this answer
























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


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f295073%2flog-the-output-of-expect-command%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









    0














    It looks like LOGFILE is out of scope, did you export it. See environment variables.



    You need to export a variable to the environment, or pass it as an argument.



    e.g.
    Let us say your program is called abc then do:



    LOGFILE=./logdir/logfile
    export LOGFILE
    ./abc


    or



    LOGFILE=./logdir/logfile ./abc


    Alternatively, pass as argument:



    ./abc "./logdir/logfile"


    And have in program:



    logfilename="$1"





    share|improve this answer
























    • YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

      – sabarish jackson
      Jul 11 '16 at 9:19











    • @sabarishjackson That logfile name ends in / so is a directory not a file.

      – meuh
      Jul 11 '16 at 10:23











    • Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

      – ctrl-alt-delor
      Jul 11 '16 at 11:58











    • @meuh I gave it as a sample. I had the path to the file_name.txt

      – sabarish jackson
      Jul 12 '16 at 5:40
















    0














    It looks like LOGFILE is out of scope, did you export it. See environment variables.



    You need to export a variable to the environment, or pass it as an argument.



    e.g.
    Let us say your program is called abc then do:



    LOGFILE=./logdir/logfile
    export LOGFILE
    ./abc


    or



    LOGFILE=./logdir/logfile ./abc


    Alternatively, pass as argument:



    ./abc "./logdir/logfile"


    And have in program:



    logfilename="$1"





    share|improve this answer
























    • YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

      – sabarish jackson
      Jul 11 '16 at 9:19











    • @sabarishjackson That logfile name ends in / so is a directory not a file.

      – meuh
      Jul 11 '16 at 10:23











    • Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

      – ctrl-alt-delor
      Jul 11 '16 at 11:58











    • @meuh I gave it as a sample. I had the path to the file_name.txt

      – sabarish jackson
      Jul 12 '16 at 5:40














    0












    0








    0







    It looks like LOGFILE is out of scope, did you export it. See environment variables.



    You need to export a variable to the environment, or pass it as an argument.



    e.g.
    Let us say your program is called abc then do:



    LOGFILE=./logdir/logfile
    export LOGFILE
    ./abc


    or



    LOGFILE=./logdir/logfile ./abc


    Alternatively, pass as argument:



    ./abc "./logdir/logfile"


    And have in program:



    logfilename="$1"





    share|improve this answer













    It looks like LOGFILE is out of scope, did you export it. See environment variables.



    You need to export a variable to the environment, or pass it as an argument.



    e.g.
    Let us say your program is called abc then do:



    LOGFILE=./logdir/logfile
    export LOGFILE
    ./abc


    or



    LOGFILE=./logdir/logfile ./abc


    Alternatively, pass as argument:



    ./abc "./logdir/logfile"


    And have in program:



    logfilename="$1"






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 11 '16 at 8:52









    ctrl-alt-delorctrl-alt-delor

    12.7k52663




    12.7k52663













    • YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

      – sabarish jackson
      Jul 11 '16 at 9:19











    • @sabarishjackson That logfile name ends in / so is a directory not a file.

      – meuh
      Jul 11 '16 at 10:23











    • Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

      – ctrl-alt-delor
      Jul 11 '16 at 11:58











    • @meuh I gave it as a sample. I had the path to the file_name.txt

      – sabarish jackson
      Jul 12 '16 at 5:40



















    • YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

      – sabarish jackson
      Jul 11 '16 at 9:19











    • @sabarishjackson That logfile name ends in / so is a directory not a file.

      – meuh
      Jul 11 '16 at 10:23











    • Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

      – ctrl-alt-delor
      Jul 11 '16 at 11:58











    • @meuh I gave it as a sample. I had the path to the file_name.txt

      – sabarish jackson
      Jul 12 '16 at 5:40

















    YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

    – sabarish jackson
    Jul 11 '16 at 9:19





    YEah I have the LOGFILE value declared earlier in my script. I didnt add it in my question. LOGFILE="/home/oracle/logs/" You want it to be exported rather than declaring it?

    – sabarish jackson
    Jul 11 '16 at 9:19













    @sabarishjackson That logfile name ends in / so is a directory not a file.

    – meuh
    Jul 11 '16 at 10:23





    @sabarishjackson That logfile name ends in / so is a directory not a file.

    – meuh
    Jul 11 '16 at 10:23













    Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

    – ctrl-alt-delor
    Jul 11 '16 at 11:58





    Edit the question to show the smallest example that still exhibits the problem, but no smaller. Do not miss out impotent bits. Test your example to check that it still exhibits your problem (not a different one).

    – ctrl-alt-delor
    Jul 11 '16 at 11:58













    @meuh I gave it as a sample. I had the path to the file_name.txt

    – sabarish jackson
    Jul 12 '16 at 5:40





    @meuh I gave it as a sample. I had the path to the file_name.txt

    – sabarish jackson
    Jul 12 '16 at 5:40













    0














    The below mentioned redirection is working fine now. I didn't add anything new.



    /usr/bin/expect<<EOD > ${LOGFILE}

    set timeout 60
    spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST:$R_LOCATION
    expect "*?assword:"
    send "$passwordr"
    expect "sftp>"
    send "put /opt/AppServer/ES_billing_report/todays_report/*.txtr"
    expect "sftp>"
    send "byer"
    expect EOD
    EOD





    share|improve this answer




























      0














      The below mentioned redirection is working fine now. I didn't add anything new.



      /usr/bin/expect<<EOD > ${LOGFILE}

      set timeout 60
      spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST:$R_LOCATION
      expect "*?assword:"
      send "$passwordr"
      expect "sftp>"
      send "put /opt/AppServer/ES_billing_report/todays_report/*.txtr"
      expect "sftp>"
      send "byer"
      expect EOD
      EOD





      share|improve this answer


























        0












        0








        0







        The below mentioned redirection is working fine now. I didn't add anything new.



        /usr/bin/expect<<EOD > ${LOGFILE}

        set timeout 60
        spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST:$R_LOCATION
        expect "*?assword:"
        send "$passwordr"
        expect "sftp>"
        send "put /opt/AppServer/ES_billing_report/todays_report/*.txtr"
        expect "sftp>"
        send "byer"
        expect EOD
        EOD





        share|improve this answer













        The below mentioned redirection is working fine now. I didn't add anything new.



        /usr/bin/expect<<EOD > ${LOGFILE}

        set timeout 60
        spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST:$R_LOCATION
        expect "*?assword:"
        send "$passwordr"
        expect "sftp>"
        send "put /opt/AppServer/ES_billing_report/todays_report/*.txtr"
        expect "sftp>"
        send "byer"
        expect EOD
        EOD






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 12 '16 at 5:39









        sabarish jacksonsabarish jackson

        159412




        159412






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f295073%2flog-the-output-of-expect-command%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

            Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

            The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

            Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...