Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
it was running fine on an amazon ec2 box (centos based) but when i moved to the actual box...
Code:
#!/bin/bash
#
# This script read access code files and verify against mysql table
#
# Declare Variables
folder="/home/ftp-docs/accesscodes/"
#file=`ls -l $folder | tail -1 | awk '{print $8}'`
file=accesscodes.txt
mysqluser=root
mysqlpass=PASSWORD
mysqlhost=192.168.0.1
# reading the file line by line
N=0
while IFS= read -r LINE ; do
N=$((N+1))
VALUE=${LINE:16:27} # cropping the record and leaving access code
# checking against database
dbexist=`mysql -h$mysqlhost -u$mysqluser -p$mysqlpass -e "SELECT id FROM database_name.accesscodes where accesscode=' $VALUE ';"`
echo dbexist $dbexist
echo $VALUE
if [ -z "$dbexist" ];then
if [ "$VALUE">0 ]; then # avoiding the null values for EOF
echo "access code $x doesn't exist on database."
fi
fi
done <$folder$file
aparently the
Code:
'$VALUE'
part of the mysql query is not getting the falue.
as you see; i've added echo $VALUE somewhere to verify if the value was picked up... and it is; but dbexist is null..
if i remove the single quote marks i have
Code:
ERROR 1054 (42S22) at line 1: Unknown column '3816253' in 'where clause'
where 3816253 is the value of $VALUE...
please help me as i'm having my brain melting here (specially by the fact that this is working on one box but not the other.
@CHris - ok thanks. SQL's not my real domain. I have run a similar query line to the OPs on my system and it runs fine, so I don't see where the server's getting confused about the field name. It's ignoring the real one in favour of the queried term.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.