Script throwing error “=: not found†[duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
This question already has an answer here:
Spaces in variable assignments in shell scripts
3 answers
Consider:
#!/bin/ksh
db2 connect to MKTETLPS user ....... using ........
db2 "select count(*) from etl.IDM_COLLAPSE_ORG_DEE c where c.IDM_PROCESS_STEP = 'I' and priority in ( '1','2','3','4','5') and c.update_ts < (current timestamp - 60 minutes) with ur" > l.txt
$a = /is115/idm/dsproj/scripts/l.txt
if [ $a -gt 0 ];
then
db2 "update etl.idm_collapse_org_dee
set idm_process_step = NULL where priority in (
'1','2','3','4','5')
and idm_process_step ='I'"
else
echo "All is well"
fi
I am running above the script and am receiving the below error. How can I fix it?
./CORCleanup1.sh[8]: =: not found.
./CORCleanup1.sh[10]: test: 0403-004 Specify a parameter with this command.
All is well
DB20000I The SQL command completed successfully.
DB20000I The TERMINATE command completed successfully.
db2 connect reset
db2 terminate
exit
shell-script ksh
marked as duplicate by ilkkachu, schily, Jeff Schaller, sebasth, maulinglawns Sep 2 at 14:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
4
down vote
favorite
This question already has an answer here:
Spaces in variable assignments in shell scripts
3 answers
Consider:
#!/bin/ksh
db2 connect to MKTETLPS user ....... using ........
db2 "select count(*) from etl.IDM_COLLAPSE_ORG_DEE c where c.IDM_PROCESS_STEP = 'I' and priority in ( '1','2','3','4','5') and c.update_ts < (current timestamp - 60 minutes) with ur" > l.txt
$a = /is115/idm/dsproj/scripts/l.txt
if [ $a -gt 0 ];
then
db2 "update etl.idm_collapse_org_dee
set idm_process_step = NULL where priority in (
'1','2','3','4','5')
and idm_process_step ='I'"
else
echo "All is well"
fi
I am running above the script and am receiving the below error. How can I fix it?
./CORCleanup1.sh[8]: =: not found.
./CORCleanup1.sh[10]: test: 0403-004 Specify a parameter with this command.
All is well
DB20000I The SQL command completed successfully.
DB20000I The TERMINATE command completed successfully.
db2 connect reset
db2 terminate
exit
shell-script ksh
marked as duplicate by ilkkachu, schily, Jeff Schaller, sebasth, maulinglawns Sep 2 at 14:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
This question already has an answer here:
Spaces in variable assignments in shell scripts
3 answers
Consider:
#!/bin/ksh
db2 connect to MKTETLPS user ....... using ........
db2 "select count(*) from etl.IDM_COLLAPSE_ORG_DEE c where c.IDM_PROCESS_STEP = 'I' and priority in ( '1','2','3','4','5') and c.update_ts < (current timestamp - 60 minutes) with ur" > l.txt
$a = /is115/idm/dsproj/scripts/l.txt
if [ $a -gt 0 ];
then
db2 "update etl.idm_collapse_org_dee
set idm_process_step = NULL where priority in (
'1','2','3','4','5')
and idm_process_step ='I'"
else
echo "All is well"
fi
I am running above the script and am receiving the below error. How can I fix it?
./CORCleanup1.sh[8]: =: not found.
./CORCleanup1.sh[10]: test: 0403-004 Specify a parameter with this command.
All is well
DB20000I The SQL command completed successfully.
DB20000I The TERMINATE command completed successfully.
db2 connect reset
db2 terminate
exit
shell-script ksh
This question already has an answer here:
Spaces in variable assignments in shell scripts
3 answers
Consider:
#!/bin/ksh
db2 connect to MKTETLPS user ....... using ........
db2 "select count(*) from etl.IDM_COLLAPSE_ORG_DEE c where c.IDM_PROCESS_STEP = 'I' and priority in ( '1','2','3','4','5') and c.update_ts < (current timestamp - 60 minutes) with ur" > l.txt
$a = /is115/idm/dsproj/scripts/l.txt
if [ $a -gt 0 ];
then
db2 "update etl.idm_collapse_org_dee
set idm_process_step = NULL where priority in (
'1','2','3','4','5')
and idm_process_step ='I'"
else
echo "All is well"
fi
I am running above the script and am receiving the below error. How can I fix it?
./CORCleanup1.sh[8]: =: not found.
./CORCleanup1.sh[10]: test: 0403-004 Specify a parameter with this command.
All is well
DB20000I The SQL command completed successfully.
DB20000I The TERMINATE command completed successfully.
db2 connect reset
db2 terminate
exit
This question already has an answer here:
Spaces in variable assignments in shell scripts
3 answers
shell-script ksh
edited Sep 1 at 14:13
Peter Mortensen
79148
79148
asked Sep 1 at 10:18


Manish Kumar
241
241
marked as duplicate by ilkkachu, schily, Jeff Schaller, sebasth, maulinglawns Sep 2 at 14:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by ilkkachu, schily, Jeff Schaller, sebasth, maulinglawns Sep 2 at 14:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
11
down vote
Variable assignments must not include $
and spaces around the =
. I also would double quote the assignment. So the variable assignment should look like as follows.
a="/is115/idm/dsproj/scripts/l.txt"
From further reading the script, it looks like you rather want to store the content of the file 1.txt
in $a
rather than the file path itself. For that purpose you could use the assignment as follows.
read -r a < /is115/idm/dsproj/scripts/l.txt
(read -r
reads the first line of the file, strips the leading and trailing spaces and tabs (assuming the default value of $IFS
) and stores it in the supplied variable)
You also may want to double quote the $a
variable in the if
statement.
if [ "$a" -gt 0 ];
You can also use https://www.shellcheck.net/ to check the syntax of your script.
Or if the file was meant as a temporary,a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn
– dave_thompson_085
Sep 2 at 1:23
add a comment |Â
up vote
4
down vote
Here's why you're seeing that error:
$a = /is115/idm/dsproj/scripts/l.txt
At this point in the code, the variable a
is unset. ksh will substitute the variable with the empty string, resulting in:
= /is115/idm/dsproj/scripts/l.txt
Then ksh attempts to execute the line, tries to locate the command =
, fails to find it, and produces the 1st error you see.
As @Thomas points out, the syntax for variable assignment is
varname=value
with no $
on the left-hand side, and no spaces around =
. https://www.shellcheck.net/ will point out these errors.
Then you have
if [ $a -gt 0 ];
Since a
has no value, ksh performs the substitution and tries to do
if [ -gt 0 ];
The [
command (yes, it is a command, aliased to the test
command) does not understand the ‑gt
operator without a left-hand operand, and you get the 2nd error message.
The [
command exits with non-zero status, the if
statement then executes the else
block, and you get the "all is well" message.
This is why it's important to quote all variables within single brackets [ ... ]
if [ "$a" -gt 0 ];
More generally, always quote variables unless you understand specifically when to omit the quotes. See also Security implications of forgetting to quote a variable in bash/POSIX shells
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
Variable assignments must not include $
and spaces around the =
. I also would double quote the assignment. So the variable assignment should look like as follows.
a="/is115/idm/dsproj/scripts/l.txt"
From further reading the script, it looks like you rather want to store the content of the file 1.txt
in $a
rather than the file path itself. For that purpose you could use the assignment as follows.
read -r a < /is115/idm/dsproj/scripts/l.txt
(read -r
reads the first line of the file, strips the leading and trailing spaces and tabs (assuming the default value of $IFS
) and stores it in the supplied variable)
You also may want to double quote the $a
variable in the if
statement.
if [ "$a" -gt 0 ];
You can also use https://www.shellcheck.net/ to check the syntax of your script.
Or if the file was meant as a temporary,a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn
– dave_thompson_085
Sep 2 at 1:23
add a comment |Â
up vote
11
down vote
Variable assignments must not include $
and spaces around the =
. I also would double quote the assignment. So the variable assignment should look like as follows.
a="/is115/idm/dsproj/scripts/l.txt"
From further reading the script, it looks like you rather want to store the content of the file 1.txt
in $a
rather than the file path itself. For that purpose you could use the assignment as follows.
read -r a < /is115/idm/dsproj/scripts/l.txt
(read -r
reads the first line of the file, strips the leading and trailing spaces and tabs (assuming the default value of $IFS
) and stores it in the supplied variable)
You also may want to double quote the $a
variable in the if
statement.
if [ "$a" -gt 0 ];
You can also use https://www.shellcheck.net/ to check the syntax of your script.
Or if the file was meant as a temporary,a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn
– dave_thompson_085
Sep 2 at 1:23
add a comment |Â
up vote
11
down vote
up vote
11
down vote
Variable assignments must not include $
and spaces around the =
. I also would double quote the assignment. So the variable assignment should look like as follows.
a="/is115/idm/dsproj/scripts/l.txt"
From further reading the script, it looks like you rather want to store the content of the file 1.txt
in $a
rather than the file path itself. For that purpose you could use the assignment as follows.
read -r a < /is115/idm/dsproj/scripts/l.txt
(read -r
reads the first line of the file, strips the leading and trailing spaces and tabs (assuming the default value of $IFS
) and stores it in the supplied variable)
You also may want to double quote the $a
variable in the if
statement.
if [ "$a" -gt 0 ];
You can also use https://www.shellcheck.net/ to check the syntax of your script.
Variable assignments must not include $
and spaces around the =
. I also would double quote the assignment. So the variable assignment should look like as follows.
a="/is115/idm/dsproj/scripts/l.txt"
From further reading the script, it looks like you rather want to store the content of the file 1.txt
in $a
rather than the file path itself. For that purpose you could use the assignment as follows.
read -r a < /is115/idm/dsproj/scripts/l.txt
(read -r
reads the first line of the file, strips the leading and trailing spaces and tabs (assuming the default value of $IFS
) and stores it in the supplied variable)
You also may want to double quote the $a
variable in the if
statement.
if [ "$a" -gt 0 ];
You can also use https://www.shellcheck.net/ to check the syntax of your script.
edited Sep 1 at 11:22


Stéphane Chazelas
283k53521857
283k53521857
answered Sep 1 at 10:41
Thomas
3,61141124
3,61141124
Or if the file was meant as a temporary,a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn
– dave_thompson_085
Sep 2 at 1:23
add a comment |Â
Or if the file was meant as a temporary,a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn
– dave_thompson_085
Sep 2 at 1:23
Or if the file was meant as a temporary,
a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn– dave_thompson_085
Sep 2 at 1:23
Or if the file was meant as a temporary,
a=$( db2 "select count(*) from tbl where cond and cond etc" )
-- though slightly less basic, command substitution is a very useful tool to learn– dave_thompson_085
Sep 2 at 1:23
add a comment |Â
up vote
4
down vote
Here's why you're seeing that error:
$a = /is115/idm/dsproj/scripts/l.txt
At this point in the code, the variable a
is unset. ksh will substitute the variable with the empty string, resulting in:
= /is115/idm/dsproj/scripts/l.txt
Then ksh attempts to execute the line, tries to locate the command =
, fails to find it, and produces the 1st error you see.
As @Thomas points out, the syntax for variable assignment is
varname=value
with no $
on the left-hand side, and no spaces around =
. https://www.shellcheck.net/ will point out these errors.
Then you have
if [ $a -gt 0 ];
Since a
has no value, ksh performs the substitution and tries to do
if [ -gt 0 ];
The [
command (yes, it is a command, aliased to the test
command) does not understand the ‑gt
operator without a left-hand operand, and you get the 2nd error message.
The [
command exits with non-zero status, the if
statement then executes the else
block, and you get the "all is well" message.
This is why it's important to quote all variables within single brackets [ ... ]
if [ "$a" -gt 0 ];
More generally, always quote variables unless you understand specifically when to omit the quotes. See also Security implications of forgetting to quote a variable in bash/POSIX shells
add a comment |Â
up vote
4
down vote
Here's why you're seeing that error:
$a = /is115/idm/dsproj/scripts/l.txt
At this point in the code, the variable a
is unset. ksh will substitute the variable with the empty string, resulting in:
= /is115/idm/dsproj/scripts/l.txt
Then ksh attempts to execute the line, tries to locate the command =
, fails to find it, and produces the 1st error you see.
As @Thomas points out, the syntax for variable assignment is
varname=value
with no $
on the left-hand side, and no spaces around =
. https://www.shellcheck.net/ will point out these errors.
Then you have
if [ $a -gt 0 ];
Since a
has no value, ksh performs the substitution and tries to do
if [ -gt 0 ];
The [
command (yes, it is a command, aliased to the test
command) does not understand the ‑gt
operator without a left-hand operand, and you get the 2nd error message.
The [
command exits with non-zero status, the if
statement then executes the else
block, and you get the "all is well" message.
This is why it's important to quote all variables within single brackets [ ... ]
if [ "$a" -gt 0 ];
More generally, always quote variables unless you understand specifically when to omit the quotes. See also Security implications of forgetting to quote a variable in bash/POSIX shells
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Here's why you're seeing that error:
$a = /is115/idm/dsproj/scripts/l.txt
At this point in the code, the variable a
is unset. ksh will substitute the variable with the empty string, resulting in:
= /is115/idm/dsproj/scripts/l.txt
Then ksh attempts to execute the line, tries to locate the command =
, fails to find it, and produces the 1st error you see.
As @Thomas points out, the syntax for variable assignment is
varname=value
with no $
on the left-hand side, and no spaces around =
. https://www.shellcheck.net/ will point out these errors.
Then you have
if [ $a -gt 0 ];
Since a
has no value, ksh performs the substitution and tries to do
if [ -gt 0 ];
The [
command (yes, it is a command, aliased to the test
command) does not understand the ‑gt
operator without a left-hand operand, and you get the 2nd error message.
The [
command exits with non-zero status, the if
statement then executes the else
block, and you get the "all is well" message.
This is why it's important to quote all variables within single brackets [ ... ]
if [ "$a" -gt 0 ];
More generally, always quote variables unless you understand specifically when to omit the quotes. See also Security implications of forgetting to quote a variable in bash/POSIX shells
Here's why you're seeing that error:
$a = /is115/idm/dsproj/scripts/l.txt
At this point in the code, the variable a
is unset. ksh will substitute the variable with the empty string, resulting in:
= /is115/idm/dsproj/scripts/l.txt
Then ksh attempts to execute the line, tries to locate the command =
, fails to find it, and produces the 1st error you see.
As @Thomas points out, the syntax for variable assignment is
varname=value
with no $
on the left-hand side, and no spaces around =
. https://www.shellcheck.net/ will point out these errors.
Then you have
if [ $a -gt 0 ];
Since a
has no value, ksh performs the substitution and tries to do
if [ -gt 0 ];
The [
command (yes, it is a command, aliased to the test
command) does not understand the ‑gt
operator without a left-hand operand, and you get the 2nd error message.
The [
command exits with non-zero status, the if
statement then executes the else
block, and you get the "all is well" message.
This is why it's important to quote all variables within single brackets [ ... ]
if [ "$a" -gt 0 ];
More generally, always quote variables unless you understand specifically when to omit the quotes. See also Security implications of forgetting to quote a variable in bash/POSIX shells
edited Sep 1 at 14:27
community wiki
2 revs
glenn jackman
add a comment |Â
add a comment |Â