Error with script that calls another script with different shell

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











up vote
-1
down vote

favorite












I have a script which runs in sh shell, this script runs fine. But I've added one script written in ksh shell ( in the head of the script there is #!/bin/ksh) but every time i get the error



./monitor_FMn2.sh[19]: 104: not found


Which every time change the second line that hit the error
The 19th line is the line where i call the ksh script



if `wc -l < $LOGFILE` > 55;
then
logcycle $LOGFILE
fi


logcycle is the ksh script.
As i'm not an expert in scripting + the line that hit errors is always different, i guess is just a syntax error.







share|improve this question




















  • Where is your logcycle script, please specify the full path in your sh script, that is safer ... your sh cannot find the file in question. is logcycle executable ?
    – thecarpy
    Nov 29 '17 at 12:38










  • logcycle is based on a directory which is declared in PATH ( /home/oracle/FM2/scripts/logcycle) and is executable -rwxr-xr-x 1 oracle dba 2189 Nov 28 14:33 /home/oracle/FM2/scripts/logcycle. The sh script can find it, otherwhise i shouldn't have the error, right?
    – FaMontyN2
    Nov 29 '17 at 12:42










  • Change logcycle to ksh /home/oracle/FM2/scripts/logcycle in your script, does that work ?
    – thecarpy
    Nov 29 '17 at 12:46










  • @thecarpy thanks for having a look. maybe i haven't been clear enough earlier, logcycle is in ksh already, is the other script that is not, it's in sh
    – FaMontyN2
    Nov 29 '17 at 12:51










  • Please clarify, which line is which ? In fact, I think you should check Steephane's answer, I guess he is on track ... $LOGFILE had 104 lines when this error occurred, and the faulty line IS NOT logcycle $LOGFILE as your question implies but the if statement above that ...
    – thecarpy
    Nov 29 '17 at 12:57















up vote
-1
down vote

favorite












I have a script which runs in sh shell, this script runs fine. But I've added one script written in ksh shell ( in the head of the script there is #!/bin/ksh) but every time i get the error



./monitor_FMn2.sh[19]: 104: not found


Which every time change the second line that hit the error
The 19th line is the line where i call the ksh script



if `wc -l < $LOGFILE` > 55;
then
logcycle $LOGFILE
fi


logcycle is the ksh script.
As i'm not an expert in scripting + the line that hit errors is always different, i guess is just a syntax error.







share|improve this question




















  • Where is your logcycle script, please specify the full path in your sh script, that is safer ... your sh cannot find the file in question. is logcycle executable ?
    – thecarpy
    Nov 29 '17 at 12:38










  • logcycle is based on a directory which is declared in PATH ( /home/oracle/FM2/scripts/logcycle) and is executable -rwxr-xr-x 1 oracle dba 2189 Nov 28 14:33 /home/oracle/FM2/scripts/logcycle. The sh script can find it, otherwhise i shouldn't have the error, right?
    – FaMontyN2
    Nov 29 '17 at 12:42










  • Change logcycle to ksh /home/oracle/FM2/scripts/logcycle in your script, does that work ?
    – thecarpy
    Nov 29 '17 at 12:46










  • @thecarpy thanks for having a look. maybe i haven't been clear enough earlier, logcycle is in ksh already, is the other script that is not, it's in sh
    – FaMontyN2
    Nov 29 '17 at 12:51










  • Please clarify, which line is which ? In fact, I think you should check Steephane's answer, I guess he is on track ... $LOGFILE had 104 lines when this error occurred, and the faulty line IS NOT logcycle $LOGFILE as your question implies but the if statement above that ...
    – thecarpy
    Nov 29 '17 at 12:57













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a script which runs in sh shell, this script runs fine. But I've added one script written in ksh shell ( in the head of the script there is #!/bin/ksh) but every time i get the error



./monitor_FMn2.sh[19]: 104: not found


Which every time change the second line that hit the error
The 19th line is the line where i call the ksh script



if `wc -l < $LOGFILE` > 55;
then
logcycle $LOGFILE
fi


logcycle is the ksh script.
As i'm not an expert in scripting + the line that hit errors is always different, i guess is just a syntax error.







share|improve this question












I have a script which runs in sh shell, this script runs fine. But I've added one script written in ksh shell ( in the head of the script there is #!/bin/ksh) but every time i get the error



./monitor_FMn2.sh[19]: 104: not found


Which every time change the second line that hit the error
The 19th line is the line where i call the ksh script



if `wc -l < $LOGFILE` > 55;
then
logcycle $LOGFILE
fi


logcycle is the ksh script.
As i'm not an expert in scripting + the line that hit errors is always different, i guess is just a syntax error.









share|improve this question











share|improve this question




share|improve this question










asked Nov 29 '17 at 12:23









FaMontyN2

639




639











  • Where is your logcycle script, please specify the full path in your sh script, that is safer ... your sh cannot find the file in question. is logcycle executable ?
    – thecarpy
    Nov 29 '17 at 12:38










  • logcycle is based on a directory which is declared in PATH ( /home/oracle/FM2/scripts/logcycle) and is executable -rwxr-xr-x 1 oracle dba 2189 Nov 28 14:33 /home/oracle/FM2/scripts/logcycle. The sh script can find it, otherwhise i shouldn't have the error, right?
    – FaMontyN2
    Nov 29 '17 at 12:42










  • Change logcycle to ksh /home/oracle/FM2/scripts/logcycle in your script, does that work ?
    – thecarpy
    Nov 29 '17 at 12:46










  • @thecarpy thanks for having a look. maybe i haven't been clear enough earlier, logcycle is in ksh already, is the other script that is not, it's in sh
    – FaMontyN2
    Nov 29 '17 at 12:51










  • Please clarify, which line is which ? In fact, I think you should check Steephane's answer, I guess he is on track ... $LOGFILE had 104 lines when this error occurred, and the faulty line IS NOT logcycle $LOGFILE as your question implies but the if statement above that ...
    – thecarpy
    Nov 29 '17 at 12:57

















  • Where is your logcycle script, please specify the full path in your sh script, that is safer ... your sh cannot find the file in question. is logcycle executable ?
    – thecarpy
    Nov 29 '17 at 12:38










  • logcycle is based on a directory which is declared in PATH ( /home/oracle/FM2/scripts/logcycle) and is executable -rwxr-xr-x 1 oracle dba 2189 Nov 28 14:33 /home/oracle/FM2/scripts/logcycle. The sh script can find it, otherwhise i shouldn't have the error, right?
    – FaMontyN2
    Nov 29 '17 at 12:42










  • Change logcycle to ksh /home/oracle/FM2/scripts/logcycle in your script, does that work ?
    – thecarpy
    Nov 29 '17 at 12:46










  • @thecarpy thanks for having a look. maybe i haven't been clear enough earlier, logcycle is in ksh already, is the other script that is not, it's in sh
    – FaMontyN2
    Nov 29 '17 at 12:51










  • Please clarify, which line is which ? In fact, I think you should check Steephane's answer, I guess he is on track ... $LOGFILE had 104 lines when this error occurred, and the faulty line IS NOT logcycle $LOGFILE as your question implies but the if statement above that ...
    – thecarpy
    Nov 29 '17 at 12:57
















Where is your logcycle script, please specify the full path in your sh script, that is safer ... your sh cannot find the file in question. is logcycle executable ?
– thecarpy
Nov 29 '17 at 12:38




Where is your logcycle script, please specify the full path in your sh script, that is safer ... your sh cannot find the file in question. is logcycle executable ?
– thecarpy
Nov 29 '17 at 12:38












logcycle is based on a directory which is declared in PATH ( /home/oracle/FM2/scripts/logcycle) and is executable -rwxr-xr-x 1 oracle dba 2189 Nov 28 14:33 /home/oracle/FM2/scripts/logcycle. The sh script can find it, otherwhise i shouldn't have the error, right?
– FaMontyN2
Nov 29 '17 at 12:42




logcycle is based on a directory which is declared in PATH ( /home/oracle/FM2/scripts/logcycle) and is executable -rwxr-xr-x 1 oracle dba 2189 Nov 28 14:33 /home/oracle/FM2/scripts/logcycle. The sh script can find it, otherwhise i shouldn't have the error, right?
– FaMontyN2
Nov 29 '17 at 12:42












Change logcycle to ksh /home/oracle/FM2/scripts/logcycle in your script, does that work ?
– thecarpy
Nov 29 '17 at 12:46




Change logcycle to ksh /home/oracle/FM2/scripts/logcycle in your script, does that work ?
– thecarpy
Nov 29 '17 at 12:46












@thecarpy thanks for having a look. maybe i haven't been clear enough earlier, logcycle is in ksh already, is the other script that is not, it's in sh
– FaMontyN2
Nov 29 '17 at 12:51




@thecarpy thanks for having a look. maybe i haven't been clear enough earlier, logcycle is in ksh already, is the other script that is not, it's in sh
– FaMontyN2
Nov 29 '17 at 12:51












Please clarify, which line is which ? In fact, I think you should check Steephane's answer, I guess he is on track ... $LOGFILE had 104 lines when this error occurred, and the faulty line IS NOT logcycle $LOGFILE as your question implies but the if statement above that ...
– thecarpy
Nov 29 '17 at 12:57





Please clarify, which line is which ? In fact, I think you should check Steephane's answer, I guess he is on track ... $LOGFILE had 104 lines when this error occurred, and the faulty line IS NOT logcycle $LOGFILE as your question implies but the if statement above that ...
– thecarpy
Nov 29 '17 at 12:57











1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










`wc -l < $LOGFILE` > 55


Runs the command whose name is the output of wc subject to split+glob (104 in your case) and redirects its output to a file called 55 in the current directory. As there's no command called 104 on your system, you get that error.



Presumably, you wanted to write:



if [ "$(($(wc -l < "$LOGFILE") +0))" -gt 55 ]; then...


That is run the [ aka test command (instead of 104) to test that the output of wc -l interpreted as an arithmetic expression (so [ doesn't complain about leading spaces if any) is greater than 55.



Or with ksh syntax:



if (($(wc -l < "$LOGFILE") +0 > 55)); then...


(the +0 to cover for the case where the wc -l < "$LOGFILE" command produces no output, like when the $LOGFILE cannot be opened for reading).



(you may also want to remove that empty 55 file created earlier by your script).






share|improve this answer






















  • thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
    – FaMontyN2
    Nov 29 '17 at 13:11











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%2f407727%2ferror-with-script-that-calls-another-script-with-different-shell%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










`wc -l < $LOGFILE` > 55


Runs the command whose name is the output of wc subject to split+glob (104 in your case) and redirects its output to a file called 55 in the current directory. As there's no command called 104 on your system, you get that error.



Presumably, you wanted to write:



if [ "$(($(wc -l < "$LOGFILE") +0))" -gt 55 ]; then...


That is run the [ aka test command (instead of 104) to test that the output of wc -l interpreted as an arithmetic expression (so [ doesn't complain about leading spaces if any) is greater than 55.



Or with ksh syntax:



if (($(wc -l < "$LOGFILE") +0 > 55)); then...


(the +0 to cover for the case where the wc -l < "$LOGFILE" command produces no output, like when the $LOGFILE cannot be opened for reading).



(you may also want to remove that empty 55 file created earlier by your script).






share|improve this answer






















  • thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
    – FaMontyN2
    Nov 29 '17 at 13:11















up vote
2
down vote



accepted










`wc -l < $LOGFILE` > 55


Runs the command whose name is the output of wc subject to split+glob (104 in your case) and redirects its output to a file called 55 in the current directory. As there's no command called 104 on your system, you get that error.



Presumably, you wanted to write:



if [ "$(($(wc -l < "$LOGFILE") +0))" -gt 55 ]; then...


That is run the [ aka test command (instead of 104) to test that the output of wc -l interpreted as an arithmetic expression (so [ doesn't complain about leading spaces if any) is greater than 55.



Or with ksh syntax:



if (($(wc -l < "$LOGFILE") +0 > 55)); then...


(the +0 to cover for the case where the wc -l < "$LOGFILE" command produces no output, like when the $LOGFILE cannot be opened for reading).



(you may also want to remove that empty 55 file created earlier by your script).






share|improve this answer






















  • thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
    – FaMontyN2
    Nov 29 '17 at 13:11













up vote
2
down vote



accepted







up vote
2
down vote



accepted






`wc -l < $LOGFILE` > 55


Runs the command whose name is the output of wc subject to split+glob (104 in your case) and redirects its output to a file called 55 in the current directory. As there's no command called 104 on your system, you get that error.



Presumably, you wanted to write:



if [ "$(($(wc -l < "$LOGFILE") +0))" -gt 55 ]; then...


That is run the [ aka test command (instead of 104) to test that the output of wc -l interpreted as an arithmetic expression (so [ doesn't complain about leading spaces if any) is greater than 55.



Or with ksh syntax:



if (($(wc -l < "$LOGFILE") +0 > 55)); then...


(the +0 to cover for the case where the wc -l < "$LOGFILE" command produces no output, like when the $LOGFILE cannot be opened for reading).



(you may also want to remove that empty 55 file created earlier by your script).






share|improve this answer














`wc -l < $LOGFILE` > 55


Runs the command whose name is the output of wc subject to split+glob (104 in your case) and redirects its output to a file called 55 in the current directory. As there's no command called 104 on your system, you get that error.



Presumably, you wanted to write:



if [ "$(($(wc -l < "$LOGFILE") +0))" -gt 55 ]; then...


That is run the [ aka test command (instead of 104) to test that the output of wc -l interpreted as an arithmetic expression (so [ doesn't complain about leading spaces if any) is greater than 55.



Or with ksh syntax:



if (($(wc -l < "$LOGFILE") +0 > 55)); then...


(the +0 to cover for the case where the wc -l < "$LOGFILE" command produces no output, like when the $LOGFILE cannot be opened for reading).



(you may also want to remove that empty 55 file created earlier by your script).







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 2 at 14:22

























answered Nov 29 '17 at 12:52









Stéphane Chazelas

282k53520854




282k53520854











  • thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
    – FaMontyN2
    Nov 29 '17 at 13:11

















  • thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
    – FaMontyN2
    Nov 29 '17 at 13:11
















thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
– FaMontyN2
Nov 29 '17 at 13:11





thanks Stephane, i knew was a syntax error. I used the first option if [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then... and it work as i wanted. Many thanks indeed
– FaMontyN2
Nov 29 '17 at 13:11


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407727%2ferror-with-script-that-calls-another-script-with-different-shell%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?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay