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









New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    2 days ago






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    2 days ago










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    2 days ago















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









New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    2 days ago






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    2 days ago










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    2 days ago













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









New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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









New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









muru

133k19282479




133k19282479






New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Barroncm

33




33




New contributor




Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Barroncm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    2 days ago






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    2 days ago










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    2 days ago














  • 1




    How did that PIPE get in there? lol that was it, Thanks!
    – Barroncm
    2 days ago






  • 1




    You need to #! before /bin/sh or it will use whatever is your current shell
    – tREEs
    2 days ago










  • yeah the "sha bang" did not play well with the code window so I left it out.
    – Barroncm
    2 days ago








1




1




How did that PIPE get in there? lol that was it, Thanks!
– Barroncm
2 days ago




How did that PIPE get in there? lol that was it, Thanks!
– Barroncm
2 days ago




1




1




You need to #! before /bin/sh or it will use whatever is your current shell
– tREEs
2 days ago




You need to #! before /bin/sh or it will use whatever is your current shell
– tREEs
2 days ago












yeah the "sha bang" did not play well with the code window so I left it out.
– Barroncm
2 days ago




yeah the "sha bang" did not play well with the code window so I left it out.
– Barroncm
2 days ago










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


    }
    });






    Barroncm is a new contributor. Be nice, and check out our Code of Conduct.










     

    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 2 days ago









        Andrea Olivato

        7281014




        7281014






















            Barroncm is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Barroncm is a new contributor. Be nice, and check out our Code of Conduct.













            Barroncm is a new contributor. Be nice, and check out our Code of Conduct.












            Barroncm is a new contributor. Be nice, and check out our Code of Conduct.















             


            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

            數位音樂下載

            When can things happen in Etherscan, such as the picture below?

            格利澤436b