php - How to values in MySQL with bash script -


i trying create bash script entering values in mysql database. ultimate goal gather data hard drives smartmontools, getting many errors decided break down , start simple. total noob @ bash / mysql. test database contains table user , date. bash script:

usr=$user date=$(date +%y%m%d) mysql -hlocalhost -uuser -ppw -dtest<<eof insert testtbl (user, date) values('$usr', $date); eof exit 

this error message get:

./ysmartmon: line 4: syntax error near unexpected token `(' ./ysmartmon: line 4: `mysql -hlocalhost -uuser -ppw -dtest<<eof insert testtbl (user, date) values('$usr', $date);' 

what doing wrong? ` need rid off? how do that?

break line after << eof, this:

mysql -hlocalhost -uuser -ppw -dtest << eof insert testtbl (user, date) values('$usr', $date); eof 

this << eof construct called here-document, can read more in man bash. search in man bash, type /here-doc , press enter.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -