Compose a path from a file name. Send file through email












0















I want to send to my e mail account a mail with log from program execution. This file changes everyday and it's named like this



log-20190703.gz


My attempt:



#!/bin/bash
log_file=logs-$(date +"%Y%m%d").gz
echo "Log file for project" | mailx -s "Log file for start_ux" -a /srv/python/myfold/proj/Log_UX/${log_file} myemail@gmail.com


that gives me an error:



log_file command not found









share|improve this question





























    0















    I want to send to my e mail account a mail with log from program execution. This file changes everyday and it's named like this



    log-20190703.gz


    My attempt:



    #!/bin/bash
    log_file=logs-$(date +"%Y%m%d").gz
    echo "Log file for project" | mailx -s "Log file for start_ux" -a /srv/python/myfold/proj/Log_UX/${log_file} myemail@gmail.com


    that gives me an error:



    log_file command not found









    share|improve this question



























      0












      0








      0








      I want to send to my e mail account a mail with log from program execution. This file changes everyday and it's named like this



      log-20190703.gz


      My attempt:



      #!/bin/bash
      log_file=logs-$(date +"%Y%m%d").gz
      echo "Log file for project" | mailx -s "Log file for start_ux" -a /srv/python/myfold/proj/Log_UX/${log_file} myemail@gmail.com


      that gives me an error:



      log_file command not found









      share|improve this question
















      I want to send to my e mail account a mail with log from program execution. This file changes everyday and it's named like this



      log-20190703.gz


      My attempt:



      #!/bin/bash
      log_file=logs-$(date +"%Y%m%d").gz
      echo "Log file for project" | mailx -s "Log file for start_ux" -a /srv/python/myfold/proj/Log_UX/${log_file} myemail@gmail.com


      that gives me an error:



      log_file command not found






      mailx






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 10:07









      Rui F Ribeiro

      41.8k1483142




      41.8k1483142










      asked Mar 7 at 10:06









      Marco FumagalliMarco Fumagalli

      1032




      1032






















          1 Answer
          1






          active

          oldest

          votes


















          0














          My mailx is using option -a to append a header to the mail. Try option -A to send an attachment.



          Edit:



          The problem was solved by OP by removing a space character "between variable name and equal sign". Option -a was correct on CentOS and not the problem.






          share|improve this answer


























          • it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

            – Marco Fumagalli
            Mar 7 at 10:18











          • @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

            – Freddy
            Mar 7 at 10:20













          • yes it exists. I can extract it and use cat on it

            – Marco Fumagalli
            Mar 7 at 10:23











          • @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

            – Freddy
            Mar 7 at 10:31













          • Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

            – Kusalananda
            Mar 7 at 10:34














          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%2f504879%2fcompose-a-path-from-a-file-name-send-file-through-email%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














          My mailx is using option -a to append a header to the mail. Try option -A to send an attachment.



          Edit:



          The problem was solved by OP by removing a space character "between variable name and equal sign". Option -a was correct on CentOS and not the problem.






          share|improve this answer


























          • it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

            – Marco Fumagalli
            Mar 7 at 10:18











          • @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

            – Freddy
            Mar 7 at 10:20













          • yes it exists. I can extract it and use cat on it

            – Marco Fumagalli
            Mar 7 at 10:23











          • @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

            – Freddy
            Mar 7 at 10:31













          • Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

            – Kusalananda
            Mar 7 at 10:34


















          0














          My mailx is using option -a to append a header to the mail. Try option -A to send an attachment.



          Edit:



          The problem was solved by OP by removing a space character "between variable name and equal sign". Option -a was correct on CentOS and not the problem.






          share|improve this answer


























          • it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

            – Marco Fumagalli
            Mar 7 at 10:18











          • @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

            – Freddy
            Mar 7 at 10:20













          • yes it exists. I can extract it and use cat on it

            – Marco Fumagalli
            Mar 7 at 10:23











          • @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

            – Freddy
            Mar 7 at 10:31













          • Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

            – Kusalananda
            Mar 7 at 10:34
















          0












          0








          0







          My mailx is using option -a to append a header to the mail. Try option -A to send an attachment.



          Edit:



          The problem was solved by OP by removing a space character "between variable name and equal sign". Option -a was correct on CentOS and not the problem.






          share|improve this answer















          My mailx is using option -a to append a header to the mail. Try option -A to send an attachment.



          Edit:



          The problem was solved by OP by removing a space character "between variable name and equal sign". Option -a was correct on CentOS and not the problem.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 7 at 11:08

























          answered Mar 7 at 10:15









          FreddyFreddy

          1,444210




          1,444210













          • it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

            – Marco Fumagalli
            Mar 7 at 10:18











          • @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

            – Freddy
            Mar 7 at 10:20













          • yes it exists. I can extract it and use cat on it

            – Marco Fumagalli
            Mar 7 at 10:23











          • @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

            – Freddy
            Mar 7 at 10:31













          • Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

            – Kusalananda
            Mar 7 at 10:34





















          • it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

            – Marco Fumagalli
            Mar 7 at 10:18











          • @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

            – Freddy
            Mar 7 at 10:20













          • yes it exists. I can extract it and use cat on it

            – Marco Fumagalli
            Mar 7 at 10:23











          • @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

            – Freddy
            Mar 7 at 10:31













          • Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

            – Kusalananda
            Mar 7 at 10:34



















          it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

          – Marco Fumagalli
          Mar 7 at 10:18





          it says Account /srv/python/myfold/proj/Log_UX/log-20190703.gz doesn't exist

          – Marco Fumagalli
          Mar 7 at 10:18













          @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

          – Freddy
          Mar 7 at 10:20







          @MarcoFumagalli But the file exists and is readable (zless /srv/python/myfold/proj/Log_UX/log-20190703.gz)?

          – Freddy
          Mar 7 at 10:20















          yes it exists. I can extract it and use cat on it

          – Marco Fumagalli
          Mar 7 at 10:23





          yes it exists. I can extract it and use cat on it

          – Marco Fumagalli
          Mar 7 at 10:23













          @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

          – Freddy
          Mar 7 at 10:31







          @MarcoFumagalli Hmm. Does (uuencode /srv/python/myfold/proj/Log_UX/${log_file} ${log_file}; echo "Log file for project") | mailx -s "Log file for start_ux" myemail@gmail.com work?

          – Freddy
          Mar 7 at 10:31















          Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

          – Kusalananda
          Mar 7 at 10:34







          Hmm... What Unix is this and what does the manual for mailx on that Unix say the correct option for attachments is? "Account ... does not exist" sounds odd. On Linux it's usually -A, BSD does not do attachments with mailx, and I'm uncertain for AIX and Solaris.

          – Kusalananda
          Mar 7 at 10:34




















          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%2f504879%2fcompose-a-path-from-a-file-name-send-file-through-email%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

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀