Script to check file in two directories using two scripts and send the results via e-mail to the user

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:



  1. strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename

  2. file core.14945

if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.



To accomplish this, I have created a shell script that will do the ff.



  1. Variable storage (environment and directories)

  2. Go to the 1st directory

  3. Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.

  4. Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).

  5. Go to 2nd directory

  6. Repeat steps 3 and 4

  7. Email the results

Now, here's my problem:



  1. I want to log the results in a text file when core files doesn't exist.

(ex. ci_core_log_%sysdate%.txt)



  1. some core files exist in a subdirectory within directory 1 or 2
    (ex. folder name: core_*)


  2. Tried to use this statement:


mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"



Result: it was sent to dvadmin@yahoo.com,kn3jer@yahoo.com, and -r@mwa00.localdomain



Expected result: dvadmin@yahoo.com,kn3jer@yahoo.com



Tried to use this instead:
mail -s "Core files exist in DV" kn3jer@yahoo.com



Result: it was sent to kn3jer@yahoo.com but the sender is dvadmin@mwa00.localdomain



I just want it to be sent to kn3jer@yahoo.com and the sender will be dvadmin@yahoo.com.



Can you please help me address these issues I have? My code is pasted here!



Many thanks!







share|improve this question

























    up vote
    0
    down vote

    favorite
    1












    I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:



    1. strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename

    2. file core.14945

    if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.



    To accomplish this, I have created a shell script that will do the ff.



    1. Variable storage (environment and directories)

    2. Go to the 1st directory

    3. Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.

    4. Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).

    5. Go to 2nd directory

    6. Repeat steps 3 and 4

    7. Email the results

    Now, here's my problem:



    1. I want to log the results in a text file when core files doesn't exist.

    (ex. ci_core_log_%sysdate%.txt)



    1. some core files exist in a subdirectory within directory 1 or 2
      (ex. folder name: core_*)


    2. Tried to use this statement:


    mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"



    Result: it was sent to dvadmin@yahoo.com,kn3jer@yahoo.com, and -r@mwa00.localdomain



    Expected result: dvadmin@yahoo.com,kn3jer@yahoo.com



    Tried to use this instead:
    mail -s "Core files exist in DV" kn3jer@yahoo.com



    Result: it was sent to kn3jer@yahoo.com but the sender is dvadmin@mwa00.localdomain



    I just want it to be sent to kn3jer@yahoo.com and the sender will be dvadmin@yahoo.com.



    Can you please help me address these issues I have? My code is pasted here!



    Many thanks!







    share|improve this question























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:



      1. strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename

      2. file core.14945

      if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.



      To accomplish this, I have created a shell script that will do the ff.



      1. Variable storage (environment and directories)

      2. Go to the 1st directory

      3. Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.

      4. Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).

      5. Go to 2nd directory

      6. Repeat steps 3 and 4

      7. Email the results

      Now, here's my problem:



      1. I want to log the results in a text file when core files doesn't exist.

      (ex. ci_core_log_%sysdate%.txt)



      1. some core files exist in a subdirectory within directory 1 or 2
        (ex. folder name: core_*)


      2. Tried to use this statement:


      mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"



      Result: it was sent to dvadmin@yahoo.com,kn3jer@yahoo.com, and -r@mwa00.localdomain



      Expected result: dvadmin@yahoo.com,kn3jer@yahoo.com



      Tried to use this instead:
      mail -s "Core files exist in DV" kn3jer@yahoo.com



      Result: it was sent to kn3jer@yahoo.com but the sender is dvadmin@mwa00.localdomain



      I just want it to be sent to kn3jer@yahoo.com and the sender will be dvadmin@yahoo.com.



      Can you please help me address these issues I have? My code is pasted here!



      Many thanks!







      share|improve this question













      I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:



      1. strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename

      2. file core.14945

      if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.



      To accomplish this, I have created a shell script that will do the ff.



      1. Variable storage (environment and directories)

      2. Go to the 1st directory

      3. Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.

      4. Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).

      5. Go to 2nd directory

      6. Repeat steps 3 and 4

      7. Email the results

      Now, here's my problem:



      1. I want to log the results in a text file when core files doesn't exist.

      (ex. ci_core_log_%sysdate%.txt)



      1. some core files exist in a subdirectory within directory 1 or 2
        (ex. folder name: core_*)


      2. Tried to use this statement:


      mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"



      Result: it was sent to dvadmin@yahoo.com,kn3jer@yahoo.com, and -r@mwa00.localdomain



      Expected result: dvadmin@yahoo.com,kn3jer@yahoo.com



      Tried to use this instead:
      mail -s "Core files exist in DV" kn3jer@yahoo.com



      Result: it was sent to kn3jer@yahoo.com but the sender is dvadmin@mwa00.localdomain



      I just want it to be sent to kn3jer@yahoo.com and the sender will be dvadmin@yahoo.com.



      Can you please help me address these issues I have? My code is pasted here!



      Many thanks!









      share|improve this question












      share|improve this question




      share|improve this question








      edited Apr 18 at 15:23









      Jeff Schaller

      31.1k846105




      31.1k846105









      asked Apr 18 at 15:00









      Jerome Sabareza

      33




      33

























          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f438530%2fscript-to-check-file-in-two-directories-using-two-scripts-and-send-the-results-v%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438530%2fscript-to-check-file-in-two-directories-using-two-scripts-and-send-the-results-v%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?