Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running mysql query from a bash shell

Status
Not open for further replies.

jhahs

Technical User
Oct 19, 2004
29
US
Trying to run a mysql query from a bash shell. I cannot get a variable to pass from the shell to the sql script.
The bash shell is part of a loop that will create the new files. Below is the bash shell I have been playing with, also is the sql script that is being used. I just inherated this and am not familuar with mysql. Mysql version 5.1.34
Thanks,
John

-- part of shell --
echo $1
set swtype=$1
mysql -u root -e "set @SWTY1='${swtype}'; source /sam/sam/AGAA/agaa.complete.unload.sql;"

--- sql ---
use AGAA;
select clli,'F'
into outfile '/tmp/CLLIs.@SWTY1.West'
fields terminated by ' '
lines terminated by '\n'
from clli
where
region = 'West' and
(dev_type = '@SWTY1' or
dev_type like '@SWTY1.%') and
(clli not in (select clli from AGAA_Permanent_Exceptions));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top