This is a discussion on get data mysql from shell within the Shell scripting forums, part of the Development/Scripting category; dear all, would u help me to get data from mysq from shell scripting? my scripts is: ################################### SQL_HOST=localhost SQL_USER=myuser ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
dear all,
would u help me to get data from mysq from shell scripting? my scripts is: ################################### SQL_HOST=localhost SQL_USER=myuser SQL_PASSWORD=mypassword SQL_DATABASE=my db MEDIA=1 DATE=`date +"%Y-%m-%d %H:%M:%S"` FROM=`formail -zx From: < $2 | sed 's/"//g'` TO=`formail -zx To: < $2` SUBJECT=`formail -zx Subject: < $2` SENT=`formail -zx Sent: < $2` TEXT=`formail -I "" <$2` if [ "$SQL_PASSWORD" != "" ]; then SQL_ARGS="-p$SQL_PASSWORD"; else SQL_ARGS=""; fi SQL_ARGS="-h $SQL_HOST -u $SQL_USER $SQL_ARGS -D $SQL_DATABASE -s -e" #KEY CODE reg=`echo "${TEXT}" | tr [A-Z] [a-z]` array=(${reg:0}) #GET ACTIVED REGISTRATION getData=`/usr/bin/mysql $SQL_ARGS "SELECT key FROM key_table WHERE status=\"0\" AND media=\"$MEDIA\";"` if [ "$getData" = "${array[0]}" ]; then /usr/bin/mysql $SQL_ARGS "UPDATE phonebook SET Name=\"${array[1]}\" WHERE msisdn=\"$FROM\";" elif [ "$getData" != "${array[0]}" ]; then /usr/bin/mysql $SQL_ARGS "INSERT INTO phonebook (msisdn,DateIn,media) values (\"$FROM\",\"$DATE\",\"$MEDIA\");"; fi ################################################ i can't get my data from $getData like Key Code? it must use mysql_fetch_assoc or the others? where the problem is? please help me. best regards. Tomi |
| Sponsored Links | ||
|
|
|
||||
|
Debug script running command
Code:
bash –x script bash –x –v script
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MYSQL master-master replication monitor shell script | zafar466 | Databases servers | 2 | 07-12-2008 01:26 PM |
| Parse XML file and store data in array in shell scripting | Nishanthhampali | Shell scripting | 5 | 02-14-2008 12:57 PM |
| Backup mysql from shell prompt or script | raj | Linux software | 0 | 07-30-2006 12:17 AM |
| Script for accessing data .. | Dastard | Shell scripting | 1 | 07-26-2006 12:12 AM |
| print data to txt | rock | Shell scripting | 1 | 03-10-2006 03:01 AM |