Cannot pass input argument to sql command in bash script
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have bash script "test.sh" and user kong in worker table. Here is my test.sh.
#!/bin/bash
result=$(mysql -s -N -u root --password='password' --execute='SELECT COUNT(*)
FROM signserver.worker WHERE User="$1"');
echo $result;
When I run the command,
./test.sh kong
the output is 0 which actually supposed to be 1. I tried to change the bash script from User="$1" to User="kong" and it's returned 1 but I want the script to be able to check from the input argument.
bash sql
New contributor
add a comment |
up vote
0
down vote
favorite
I have bash script "test.sh" and user kong in worker table. Here is my test.sh.
#!/bin/bash
result=$(mysql -s -N -u root --password='password' --execute='SELECT COUNT(*)
FROM signserver.worker WHERE User="$1"');
echo $result;
When I run the command,
./test.sh kong
the output is 0 which actually supposed to be 1. I tried to change the bash script from User="$1" to User="kong" and it's returned 1 but I want the script to be able to check from the input argument.
bash sql
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have bash script "test.sh" and user kong in worker table. Here is my test.sh.
#!/bin/bash
result=$(mysql -s -N -u root --password='password' --execute='SELECT COUNT(*)
FROM signserver.worker WHERE User="$1"');
echo $result;
When I run the command,
./test.sh kong
the output is 0 which actually supposed to be 1. I tried to change the bash script from User="$1" to User="kong" and it's returned 1 but I want the script to be able to check from the input argument.
bash sql
New contributor
I have bash script "test.sh" and user kong in worker table. Here is my test.sh.
#!/bin/bash
result=$(mysql -s -N -u root --password='password' --execute='SELECT COUNT(*)
FROM signserver.worker WHERE User="$1"');
echo $result;
When I run the command,
./test.sh kong
the output is 0 which actually supposed to be 1. I tried to change the bash script from User="$1" to User="kong" and it's returned 1 but I want the script to be able to check from the input argument.
bash sql
bash sql
New contributor
New contributor
New contributor
asked Nov 22 at 9:43
Kong
11
11
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Kong is a new contributor. Be nice, and check out our Code of Conduct.
Kong is a new contributor. Be nice, and check out our Code of Conduct.
Kong is a new contributor. Be nice, and check out our Code of Conduct.
Kong 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%2funix.stackexchange.com%2fquestions%2f483400%2fcannot-pass-input-argument-to-sql-command-in-bash-script%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