Bash issues with output
up vote
0
down vote
favorite
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
New contributor
add a comment |
up vote
0
down vote
favorite
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
New contributor
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
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
New contributor
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
bash
New contributor
New contributor
edited 2 days ago
muru
133k19282479
133k19282479
New contributor
asked 2 days ago
Barroncm
33
33
New contributor
New contributor
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered 2 days ago
Andrea Olivato
7281014
7281014
add a comment |
add a comment |
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.
Barroncm is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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