-1

2 Days to find the way and nothing happened. How can i insert image blob directly from shell script and display the image by php files?

Shell script :

#!/bin/bash
DB_USER = "root";
DB_PASS = "";
DB_NAME = "raven";
TABLE = "gambar";

killall motion
sleep 1
TANGGAL = $(date +"%Y-%m-%d_%H-%M-%S");
raspistill -t 2000 -w 1280 -h 720 -q 100 -o /var/www/html/$TANGGAL.jpg
sleep 1

mysql --user=$DB_USER --password=$DB_PASS $DB_NAME << EOF
INSERT INTO $TABLE VALUES (NULL,$TANGGAL, LOAD_FILE('/var/www/html/$TANGGAL.jpg'));
EOF
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • So, what's the problem? Questions are encouraged to provide a [Minimum Complete and Verifiable Example](https://stackoverflow.com/help/mcve), try to [improve](https://stackoverflow.com/help/how-to-ask) yours. – LMC May 18 '18 at 21:36
  • If you feed https://www.shellcheck.net/ with your script (you always should), it'll tell you that you must not put spaces around `=` in assignments. – Benjamin W. May 18 '18 at 22:01

1 Answers1

0

This should work,

#!/bin/bash
DB_USER="root";
DB_PASS="";
DB_NAME="raven";
TABLE="gambar";

killall motion
sleep 1
TANGGAL=$(date +"%Y-%m-%d_%H-%M-%S");
raspistill -t 2000 -w 1280 -h 720 -q 100 -o     /var/www/html/"$TANGGAL".jpg
sleep 1

mysql -u "$DB_USER" -p"$DB_PASS" -D $DB_NAME -e <<EOF
INSERT INTO $TABLE VALUES (NULL,$TANGGAL,     LOAD_FILE('/var/www/html/$TANGGAL.jpg'));
EOF

Note there is no space between -p and password, that is not a typo.

Eby Jacob
  • 1,418
  • 1
  • 10
  • 28