#usernamecheck.sh
#!/bin/bsh
DBUSER=user_1
DBPASSWORD=XXXXX
DBSOURCENAME=database_1
DBNAME=database_1
DBNAME1=snapshot_v
DBSERVER=X.X.X.X
DBCONN="-h ${DBSERVER} -u ${DBUSER} --password=${DBPASSWORD}"
echo "select user from device_id where ip='1.1.1.1'|mysql $DBCONN $DBNAME
The output of executing this script is:
user
----
JohnDoe
The above bash script which gives me user name of IP (1.1.1.1). I would like to pass the IP as a command line argument. I tried,
echo "select user from device_id where ip=$1|mysql $DBCONN $DBNAME
and executed like
$./usernamecheck.sh '1.1.1.1'
I get the error message:
Error in SQL syntax
Hope i'm passing the command line argument correct. But not sure, why does this error pop up?