Bash issues with output











up vote
0
down vote

favorite
1












I have the following script:



/bin/sh
echo "Compare Ran" $(date) >> /var/log/ran.log
if cmp -s "/var/log/ip.log" "/etc/wanip.log"
then
echo "Wan Check Ran" | /var/log/ran.log
else
echo "WARNING IP CHANGE" | sendmail *********@email.****.net
fi


If the 2 files don't match the script works great but if the 2 files match I get the following output:



/var/log/ran.log: 1: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 2: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 3: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 4: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 5: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 6: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 7: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 8: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 9: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 10: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 11: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 12: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 13: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 14: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 15: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 16: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 17: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 18: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 19: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 20: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 21: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 22: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 23: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 24: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 25: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 26: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 27: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 28: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 29: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 30: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 31: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 32: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 33: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 34: /var/log/ran.log: Thu: not found
/var/log/ran.log: 35: /var/log/ran.log: Compare: not found
/var/log/ran.log: 36: /var/log/ran.log: Compare: not found
/var/log/ran.log: 37: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 38: /var/log/ran.log: Compare: not found


I can not for the life of me figure out why the script seems to be "reading" the ran.log file if the 2 files are the same.



Any Ideas?










share|improve this question




















  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    Nov 16 at 1:31






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    Nov 16 at 1:37










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    Nov 16 at 4:48















up vote
0
down vote

favorite
1












I have the following script:



/bin/sh
echo "Compare Ran" $(date) >> /var/log/ran.log
if cmp -s "/var/log/ip.log" "/etc/wanip.log"
then
echo "Wan Check Ran" | /var/log/ran.log
else
echo "WARNING IP CHANGE" | sendmail *********@email.****.net
fi


If the 2 files don't match the script works great but if the 2 files match I get the following output:



/var/log/ran.log: 1: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 2: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 3: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 4: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 5: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 6: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 7: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 8: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 9: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 10: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 11: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 12: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 13: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 14: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 15: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 16: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 17: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 18: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 19: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 20: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 21: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 22: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 23: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 24: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 25: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 26: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 27: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 28: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 29: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 30: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 31: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 32: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 33: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 34: /var/log/ran.log: Thu: not found
/var/log/ran.log: 35: /var/log/ran.log: Compare: not found
/var/log/ran.log: 36: /var/log/ran.log: Compare: not found
/var/log/ran.log: 37: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 38: /var/log/ran.log: Compare: not found


I can not for the life of me figure out why the script seems to be "reading" the ran.log file if the 2 files are the same.



Any Ideas?










share|improve this question




















  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    Nov 16 at 1:31






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    Nov 16 at 1:37










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    Nov 16 at 4:48













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I have the following script:



/bin/sh
echo "Compare Ran" $(date) >> /var/log/ran.log
if cmp -s "/var/log/ip.log" "/etc/wanip.log"
then
echo "Wan Check Ran" | /var/log/ran.log
else
echo "WARNING IP CHANGE" | sendmail *********@email.****.net
fi


If the 2 files don't match the script works great but if the 2 files match I get the following output:



/var/log/ran.log: 1: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 2: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 3: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 4: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 5: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 6: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 7: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 8: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 9: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 10: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 11: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 12: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 13: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 14: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 15: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 16: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 17: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 18: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 19: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 20: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 21: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 22: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 23: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 24: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 25: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 26: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 27: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 28: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 29: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 30: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 31: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 32: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 33: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 34: /var/log/ran.log: Thu: not found
/var/log/ran.log: 35: /var/log/ran.log: Compare: not found
/var/log/ran.log: 36: /var/log/ran.log: Compare: not found
/var/log/ran.log: 37: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 38: /var/log/ran.log: Compare: not found


I can not for the life of me figure out why the script seems to be "reading" the ran.log file if the 2 files are the same.



Any Ideas?










share|improve this question















I have the following script:



/bin/sh
echo "Compare Ran" $(date) >> /var/log/ran.log
if cmp -s "/var/log/ip.log" "/etc/wanip.log"
then
echo "Wan Check Ran" | /var/log/ran.log
else
echo "WARNING IP CHANGE" | sendmail *********@email.****.net
fi


If the 2 files don't match the script works great but if the 2 files match I get the following output:



/var/log/ran.log: 1: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 2: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 3: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 4: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 5: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 6: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 7: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 8: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 9: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 10: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 11: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 12: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 13: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 14: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 15: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 16: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 17: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 18: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 19: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 20: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 21: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 22: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 23: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 24: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 25: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 26: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 27: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 28: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 29: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 30: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 31: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 32: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 33: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 34: /var/log/ran.log: Thu: not found
/var/log/ran.log: 35: /var/log/ran.log: Compare: not found
/var/log/ran.log: 36: /var/log/ran.log: Compare: not found
/var/log/ran.log: 37: /var/log/ran.log: wanip.sh: not found
/var/log/ran.log: 38: /var/log/ran.log: Compare: not found


I can not for the life of me figure out why the script seems to be "reading" the ran.log file if the 2 files are the same.



Any Ideas?







bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 at 1:39









muru

134k19282482




134k19282482










asked Nov 16 at 1:15









Barroncm

33




33








  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    Nov 16 at 1:31






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    Nov 16 at 1:37










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    Nov 16 at 4:48














  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    Nov 16 at 1:31






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    Nov 16 at 1:37










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    Nov 16 at 4:48








1




1




How did that PIPE get in there? lol that was it, Thanks!
– Barroncm
Nov 16 at 1:31




How did that PIPE get in there? lol that was it, Thanks!
– Barroncm
Nov 16 at 1:31




1




1




You need to #! before /bin/sh or it will use whatever is your current shell
– tREEs
Nov 16 at 1:37




You need to #! before /bin/sh or it will use whatever is your current shell
– tREEs
Nov 16 at 1:37












yeah the "sha bang" did not play well with the code window so I left it out.
– Barroncm
Nov 16 at 4:48




yeah the "sha bang" did not play well with the code window so I left it out.
– Barroncm
Nov 16 at 4:48










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










This line of code is trying to execute '/var/log/ran.log' as a script



echo "Wan Check Ran" | /var/log/ran.log


While I believe that you want to add the string "Wan Check Ran" to the log. Therefore you should



echo "Wan Check Ran" >> /var/log/ran.log





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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: 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%2faskubuntu.com%2fquestions%2f1093346%2fbash-issues-with-output%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








    up vote
    3
    down vote



    accepted










    This line of code is trying to execute '/var/log/ran.log' as a script



    echo "Wan Check Ran" | /var/log/ran.log


    While I believe that you want to add the string "Wan Check Ran" to the log. Therefore you should



    echo "Wan Check Ran" >> /var/log/ran.log





    share|improve this answer

























      up vote
      3
      down vote



      accepted










      This line of code is trying to execute '/var/log/ran.log' as a script



      echo "Wan Check Ran" | /var/log/ran.log


      While I believe that you want to add the string "Wan Check Ran" to the log. Therefore you should



      echo "Wan Check Ran" >> /var/log/ran.log





      share|improve this answer























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        This line of code is trying to execute '/var/log/ran.log' as a script



        echo "Wan Check Ran" | /var/log/ran.log


        While I believe that you want to add the string "Wan Check Ran" to the log. Therefore you should



        echo "Wan Check Ran" >> /var/log/ran.log





        share|improve this answer












        This line of code is trying to execute '/var/log/ran.log' as a script



        echo "Wan Check Ran" | /var/log/ran.log


        While I believe that you want to add the string "Wan Check Ran" to the log. Therefore you should



        echo "Wan Check Ran" >> /var/log/ran.log






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 at 1:25









        Andrea Olivato

        7481014




        7481014






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1093346%2fbash-issues-with-output%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

            mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?