Error with script that calls another script with different shell
Clash 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.
shell-script shell scripting
 |Â
show 1 more comment
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.
shell-script shell scripting
Where is yourlogcycle
script, please specify the full path in your sh script, that is safer ... yoursh
cannot find the file in question. islogcycle
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
Changelogcycle
toksh /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 NOTlogcycle $LOGFILE
as your question implies but theif
statement above that ...
â thecarpy
Nov 29 '17 at 12:57
 |Â
show 1 more comment
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.
shell-script shell scripting
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.
shell-script shell scripting
asked Nov 29 '17 at 12:23
FaMontyN2
639
639
Where is yourlogcycle
script, please specify the full path in your sh script, that is safer ... yoursh
cannot find the file in question. islogcycle
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
Changelogcycle
toksh /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 NOTlogcycle $LOGFILE
as your question implies but theif
statement above that ...
â thecarpy
Nov 29 '17 at 12:57
 |Â
show 1 more comment
Where is yourlogcycle
script, please specify the full path in your sh script, that is safer ... yoursh
cannot find the file in question. islogcycle
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
Changelogcycle
toksh /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 NOTlogcycle $LOGFILE
as your question implies but theif
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
 |Â
show 1 more comment
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).
thanks Stephane, i knew was a syntax error. I used the first optionif [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then...
and it work as i wanted. Many thanks indeed
â FaMontyN2
Nov 29 '17 at 13:11
add a comment |Â
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).
thanks Stephane, i knew was a syntax error. I used the first optionif [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then...
and it work as i wanted. Many thanks indeed
â FaMontyN2
Nov 29 '17 at 13:11
add a comment |Â
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).
thanks Stephane, i knew was a syntax error. I used the first optionif [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then...
and it work as i wanted. Many thanks indeed
â FaMontyN2
Nov 29 '17 at 13:11
add a comment |Â
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).
`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).
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 optionif [ "$(($(wc -l < "$LOGFILE")))" -gt 55 ]; then...
and it work as i wanted. Many thanks indeed
â FaMontyN2
Nov 29 '17 at 13:11
add a comment |Â
thanks Stephane, i knew was a syntax error. I used the first optionif [ "$(($(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
add a comment |Â
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
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
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
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
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
Where is your
logcycle
script, please specify the full path in your sh script, that is safer ... yoursh
cannot find the file in question. islogcycle
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
toksh /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 NOTlogcycle $LOGFILE
as your question implies but theif
statement above that ...â thecarpy
Nov 29 '17 at 12:57