check file of sftp and return output to logredirect and log script outputHow to do a grep on remote machine...

What would Earth look like at night in medieval times?

Why cruise at 7000' in an A319?

Simple object validator with a new API

Why does Darth Sidious need bodyguards?

How can I convince my reader that I will not use a certain trope?

"It will become the talk of Paris" - translation into French

Do French speakers not use the subjunctive informally?

Does image quality of the lens affect "focus and recompose" technique?

Should I hide continue button until tasks are completed?

Alphabet completion rate

What happens when your group is victim of a surprise attack but you can't be surprised?

What is the line crossing the Pacific Ocean that is shown on maps?

How many satellites can stay in a Lagrange point?

Why isn’t the tax system continuous rather than bracketed?

How should I behave to assure my friends that I am not after their money?

What are the penalties for overstaying in USA?

Finding closed forms for various addition laws on elliptic curves, FullSimplify fails even with assumptions?

Why does the numerical solution of an ODE move away from an unstable equilibrium?

Correct spacing in the alignat*-environment

What determines the "strength of impact" of a falling object on the ground, momentum or energy?

Is there any set of 2-6 notes that doesn't have a chord name?

Declining an offer to present a poster instead of a paper

Does squid ink pasta bleed?

Find smallest index that is identical to the value in an array



check file of sftp and return output to log


redirect and log script outputHow to do a grep on remote machine and print out the line which contains those words?bash: how do you return file extensions?handle large number of same log using cron or logrotatescript: Log both output and exit codescheck log file if job status is not startedSFTP script not working with cron jobadd script will not return intended outputSFTP: check if downloaded correctlyfind: failed to restore initial working directory: Permission denied






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







0















I need your assistance.
I'm trying to finish a script that I've done but it is not working perfectly.



here is the script:



#!/bin/bash
#
iclog=log
key="keys/cash_prod_key"
date=$(date +%Y%m%d)
logname="logfile_${date}vendor.log"
file="filename_20190621_vendor"
logdate=$(date +%Y%m%d%H%M%S);
flag="N"


#REMOVING LOG FILES OLDER THAN 30 DAYS

find $iclog -type f -name "filename_*_vendor.log" -follow -mtime +30 -exec rm {} ; -print


#----Log File---------#



#SFTP CHECK

#echo Log BEGIN For $logdate>$iclog/$logname

exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1> $iclog/$logname 2>&1


while [ "$flag" != "Y" ]
do
sftp -b - -oPort=6022 user@sftp_host << EOF
ls -la $file
bye
EOF

if [[ -f $file ]]; then
inf_log "File is available on the vendor........."
sftp -b - -oPort=6022 user@sftp_host <<EOF
ls -la $file
bye
EOF
flag='Y'
else
sleep 300
fi
done

#-------Check file availability--------#

grep -q "$file" $iclog/$logname

if [ $? -eq 0 ]; then
inf_log "File available!"
else
err " File is not Found!!! - Please call Support ASAP"
exit 1
fi


So when I'm running the script in debug mode I get the following output:



$ bash -x ./check.sh
+ iclog=log
+ key=keys/cash_prod_key
++ date +%Y%m%d
+ date=20190623
+ logname=filename_20190623_vendor.log
+ file=filename_20190621_vendor
++ date +%Y%m%d%H%M%S
+ logdate=20190623062939
+ flag=N
+ find log -type f -name 'filename_*_vendor.log' -follow -mtime +30 -exec rm '{}' ';' -print
+ exec
+ trap 'exec 2>&4 1>&3' 0 1 2 3
+ exec


And stays in this step executing the script, it doesn't advance for the grep in the log file.
from the log file, it seems that even finding the file it sleeps.



Could you please assist me so the file can be checked on the log file and return output for that same log file?



Thank you all










share|improve this question































    0















    I need your assistance.
    I'm trying to finish a script that I've done but it is not working perfectly.



    here is the script:



    #!/bin/bash
    #
    iclog=log
    key="keys/cash_prod_key"
    date=$(date +%Y%m%d)
    logname="logfile_${date}vendor.log"
    file="filename_20190621_vendor"
    logdate=$(date +%Y%m%d%H%M%S);
    flag="N"


    #REMOVING LOG FILES OLDER THAN 30 DAYS

    find $iclog -type f -name "filename_*_vendor.log" -follow -mtime +30 -exec rm {} ; -print


    #----Log File---------#



    #SFTP CHECK

    #echo Log BEGIN For $logdate>$iclog/$logname

    exec 3>&1 4>&2
    trap 'exec 2>&4 1>&3' 0 1 2 3
    exec 1> $iclog/$logname 2>&1


    while [ "$flag" != "Y" ]
    do
    sftp -b - -oPort=6022 user@sftp_host << EOF
    ls -la $file
    bye
    EOF

    if [[ -f $file ]]; then
    inf_log "File is available on the vendor........."
    sftp -b - -oPort=6022 user@sftp_host <<EOF
    ls -la $file
    bye
    EOF
    flag='Y'
    else
    sleep 300
    fi
    done

    #-------Check file availability--------#

    grep -q "$file" $iclog/$logname

    if [ $? -eq 0 ]; then
    inf_log "File available!"
    else
    err " File is not Found!!! - Please call Support ASAP"
    exit 1
    fi


    So when I'm running the script in debug mode I get the following output:



    $ bash -x ./check.sh
    + iclog=log
    + key=keys/cash_prod_key
    ++ date +%Y%m%d
    + date=20190623
    + logname=filename_20190623_vendor.log
    + file=filename_20190621_vendor
    ++ date +%Y%m%d%H%M%S
    + logdate=20190623062939
    + flag=N
    + find log -type f -name 'filename_*_vendor.log' -follow -mtime +30 -exec rm '{}' ';' -print
    + exec
    + trap 'exec 2>&4 1>&3' 0 1 2 3
    + exec


    And stays in this step executing the script, it doesn't advance for the grep in the log file.
    from the log file, it seems that even finding the file it sleeps.



    Could you please assist me so the file can be checked on the log file and return output for that same log file?



    Thank you all










    share|improve this question



























      0












      0








      0








      I need your assistance.
      I'm trying to finish a script that I've done but it is not working perfectly.



      here is the script:



      #!/bin/bash
      #
      iclog=log
      key="keys/cash_prod_key"
      date=$(date +%Y%m%d)
      logname="logfile_${date}vendor.log"
      file="filename_20190621_vendor"
      logdate=$(date +%Y%m%d%H%M%S);
      flag="N"


      #REMOVING LOG FILES OLDER THAN 30 DAYS

      find $iclog -type f -name "filename_*_vendor.log" -follow -mtime +30 -exec rm {} ; -print


      #----Log File---------#



      #SFTP CHECK

      #echo Log BEGIN For $logdate>$iclog/$logname

      exec 3>&1 4>&2
      trap 'exec 2>&4 1>&3' 0 1 2 3
      exec 1> $iclog/$logname 2>&1


      while [ "$flag" != "Y" ]
      do
      sftp -b - -oPort=6022 user@sftp_host << EOF
      ls -la $file
      bye
      EOF

      if [[ -f $file ]]; then
      inf_log "File is available on the vendor........."
      sftp -b - -oPort=6022 user@sftp_host <<EOF
      ls -la $file
      bye
      EOF
      flag='Y'
      else
      sleep 300
      fi
      done

      #-------Check file availability--------#

      grep -q "$file" $iclog/$logname

      if [ $? -eq 0 ]; then
      inf_log "File available!"
      else
      err " File is not Found!!! - Please call Support ASAP"
      exit 1
      fi


      So when I'm running the script in debug mode I get the following output:



      $ bash -x ./check.sh
      + iclog=log
      + key=keys/cash_prod_key
      ++ date +%Y%m%d
      + date=20190623
      + logname=filename_20190623_vendor.log
      + file=filename_20190621_vendor
      ++ date +%Y%m%d%H%M%S
      + logdate=20190623062939
      + flag=N
      + find log -type f -name 'filename_*_vendor.log' -follow -mtime +30 -exec rm '{}' ';' -print
      + exec
      + trap 'exec 2>&4 1>&3' 0 1 2 3
      + exec


      And stays in this step executing the script, it doesn't advance for the grep in the log file.
      from the log file, it seems that even finding the file it sleeps.



      Could you please assist me so the file can be checked on the log file and return output for that same log file?



      Thank you all










      share|improve this question
















      I need your assistance.
      I'm trying to finish a script that I've done but it is not working perfectly.



      here is the script:



      #!/bin/bash
      #
      iclog=log
      key="keys/cash_prod_key"
      date=$(date +%Y%m%d)
      logname="logfile_${date}vendor.log"
      file="filename_20190621_vendor"
      logdate=$(date +%Y%m%d%H%M%S);
      flag="N"


      #REMOVING LOG FILES OLDER THAN 30 DAYS

      find $iclog -type f -name "filename_*_vendor.log" -follow -mtime +30 -exec rm {} ; -print


      #----Log File---------#



      #SFTP CHECK

      #echo Log BEGIN For $logdate>$iclog/$logname

      exec 3>&1 4>&2
      trap 'exec 2>&4 1>&3' 0 1 2 3
      exec 1> $iclog/$logname 2>&1


      while [ "$flag" != "Y" ]
      do
      sftp -b - -oPort=6022 user@sftp_host << EOF
      ls -la $file
      bye
      EOF

      if [[ -f $file ]]; then
      inf_log "File is available on the vendor........."
      sftp -b - -oPort=6022 user@sftp_host <<EOF
      ls -la $file
      bye
      EOF
      flag='Y'
      else
      sleep 300
      fi
      done

      #-------Check file availability--------#

      grep -q "$file" $iclog/$logname

      if [ $? -eq 0 ]; then
      inf_log "File available!"
      else
      err " File is not Found!!! - Please call Support ASAP"
      exit 1
      fi


      So when I'm running the script in debug mode I get the following output:



      $ bash -x ./check.sh
      + iclog=log
      + key=keys/cash_prod_key
      ++ date +%Y%m%d
      + date=20190623
      + logname=filename_20190623_vendor.log
      + file=filename_20190621_vendor
      ++ date +%Y%m%d%H%M%S
      + logdate=20190623062939
      + flag=N
      + find log -type f -name 'filename_*_vendor.log' -follow -mtime +30 -exec rm '{}' ';' -print
      + exec
      + trap 'exec 2>&4 1>&3' 0 1 2 3
      + exec


      And stays in this step executing the script, it doesn't advance for the grep in the log file.
      from the log file, it seems that even finding the file it sleeps.



      Could you please assist me so the file can be checked on the log file and return output for that same log file?



      Thank you all







      linux bash networking scripting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago







      anmoreira

















      asked 1 hour ago









      anmoreiraanmoreira

      113 bronze badges




      113 bronze badges






















          0






          active

          oldest

          votes














          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%2f526456%2fcheck-file-of-sftp-and-return-output-to-log%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f526456%2fcheck-file-of-sftp-and-return-output-to-log%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m