unix - Passing multiple parameters from shell script to mysql query -
i have write unix shell script take parameters mysql , export result csv file. have written extent unable pass multiple parameters shell script sql.
can me out in this? thanks!!
assuming call script $ ./script param1 param2 param3
in script
echo $0 #will echo 'script' (the name of script) echo $1 #will echo 'param1' echo $2 #will echo 'param2' echo $3 #will echo 'param3' echo $# #will echo '3' number of params passed script echo $@ #will echo 'param1 param2 param3' (all parameters passed) host="127.0.0.1" user="root" password="pass" result=`mysql -h $host --user=$user --password=$password --skip-column-names -e "select $param1 $param2 $param3 = 3"` echo $result
Comments
Post a Comment