syntax issue with quotes in mysql command for a bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax issue with quotes in mysql command for a bash script
# 1  
Old 04-21-2012
syntax issue with quotes in mysql command for a bash script

i'm trying to write a bash script that executes a mysql statement

mysql -sN -e INSERT INTO "$database"."$tableprefix"users (var1, var2,var3) VALUES (123, '1','')


i don't know where to put the quotes
it doesnt work with this one: `

it seems i can only put double quotes around the variables like $prefix

but if i put a single or double quote, or parrenthesis around the insert statement, it doesnt work..


how do i run this insert statement from a bash script?

thanks!

---------- Post updated at 03:32 AM ---------- Previous update was at 03:03 AM ----------

i figured it out
i put the query in between
EOF
and it worked

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with quotes when running SQL command from within su -c

RHEL 6.2/Bash shell root user will be executing the below script. It switches to oracle user logs in using sqlplus and tries to run the below UPDATE statement. All the commands after su -c are enclosed in a single quote delimited by semicolon. The execution has failed because the quotes... (3 Replies)
Discussion started by: omega3
3 Replies

2. Web Development

Bash Script, ec2addtag syntax?

ec2addtag --region us-west-1 vol1234 --tag Name=$nameinst; It should execute ec2addtag --region us-west-1 vol1234 --tag Name=webserver; Instead it thinks that Name is equal to that variable. Please help. Thanks! Please use code tags! (0 Replies)
Discussion started by: svalenciatech
0 Replies

3. Shell Programming and Scripting

Issue with Single Quotes and Double Quotes for prompt PS1

Hi, Trying to change the prompt. I have the following code. export PS1=' <${USER}@`hostname -s`>$ ' The hostname is not displayed <abc@`hostname -s`>$ uname -a AIX xyz 1 6 00F736154C00 <adcwl4h@`hostname -s`>$ If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies

4. Shell Programming and Scripting

Nested double quotes won't work in my bash script?

In a bash script I have: LSCMD="find /project/media/ -mindepth 2 -maxdepth 2 -name \"files*pkg\"" ALL_PACKAGES=$( $LSCMD | sort 2>/dev/null) But I get nothing returned. It's just all blank. If I run the find command in a terminal, I get dozens of hits. I figure it's the way how I'm... (3 Replies)
Discussion started by: superbbrr
3 Replies

5. Shell Programming and Scripting

syntax issue mysql in bash script

I'm running mysql in a bash script mysql <<EOF query EOF one query is like this: UPDATE $dbname.$prefix"config" SET value = $var WHERE "$prefix"config.name = 'table colname'; with variable but it's giving an error i'm not sure what to put for "$prefix"config.name the table... (3 Replies)
Discussion started by: vanessafan99
3 Replies

6. Shell Programming and Scripting

How to run bash script from within MySQL

Can someone tell me the syntax to run a shell script from within MySQL? I know there is a way to do it, but I can't remember the syntax. I thought it was something like: mysql> \. /user/myscript; but I get this error: Failed to open file '/user/myscript;', error: 2 Please help!... (4 Replies)
Discussion started by: peterv6
4 Replies

7. Shell Programming and Scripting

bash syntax error: command not found

I am trying to create a shell that asks the user to enter their name, and compare it to my own by saying we have the same name or saying my name and that they have a nice name too. Here is my script... #!/bin/bash-x echo "Enter your name". read name if then echo "My name is Adam too"... (1 Reply)
Discussion started by: amaxey45
1 Replies

8. Shell Programming and Scripting

Help with a possiable syntax issue in my script

Hello I have tried to my best ability to work around this script tht will reference my m-names.txt which contains the format of: 168.16.0.0/16 169.56.0.0/16 132.2.0.0/16 122.5.0.0/16 Then I call a cli named getzoneprof that will set the $subnet from each of the lines in the... (6 Replies)
Discussion started by: richsark
6 Replies

9. Shell Programming and Scripting

BASH Script syntax error

I'm trying to write a simple script that takes all the .tar.gz files in a directory and verifies them by using the gzip -tv command: for zip in *.tar.gz do gzip -tv $zip if ; then #Check return code from tar echo "File ${zip} verified OK." exit... (4 Replies)
Discussion started by: kelldan
4 Replies

10. Shell Programming and Scripting

Retain quotes from bash script arguments

Hi there, I've been scouring these forums and have found similar threads, but none apparently helped me solved my problem :rolleyes: I'd like to run a command within a bash script, but that command is provided by the user to the script and may contain quotes, which is where the problem lies.... (9 Replies)
Discussion started by: cypression
9 Replies
Login or Register to Ask a Question
PMDAMYSQL(1)						       Performance Co-Pilot						      PMDAMYSQL(1)

NAME
pmdamysql - MySQL database PMDA DESCRIPTION
pmdamysql is a Performance Co-Pilot PMDA which extracts live performance data from a running MySQL database. INSTALLATION
pmdamysql uses a configuration file from (in this order): o /etc/pcpdbi.conf o $PCP_PMDAS_DIR/mysql/mysql.conf This file can contain overridden values (Perl code) for the settings listed at the start of pmdamysql.pl, namely: o database name (see DBI(3) for details) o database user name o database pass word Once this is setup, you can access the names and values for the mysql performance metrics by doing the following as root: # cd $PCP_PMDAS_DIR/mysql # ./Install If you want to undo the installation, do the following as root: # cd $PCP_PMDAS_DIR/mysql # ./Remove pmdamysql is launched by pmcd(1) and should never be executed directly. The Install and Remove scripts notify pmcd(1) when the agent is installed or removed. Binary Status values in text Some of the status values are in the form of YES/NO or ON/OFF. Since these cannot be intepreted by tools like PMIE, they have been duplicated with a _num extension and the values of 1 (YES/ON) or 0 (NO/OFF). Eg: o mysql.slave_status.slave_io_running o mysql.slave_status.slave_io_running_num FILES
/etc/pcpdbi.conf configuration file for all PCP database monitors $PCP_PMDAS_DIR/mysql/mysql.conf configuration file for pmdamysql $PCP_PMDAS_DIR/mysql/Install installation script for the pmdamysql agent $PCP_PMDAS_DIR/mysql/Remove undo installation script for the pmdamysql agent $PCP_LOG_DIR/pmcd/mysql.log default log file for error messages from pmdamysql SEE ALSO
pmcd(1), pmdadbping.pl(1) and DBI(3). # vi: sw=4 ts=4 et: 3.8.10 Performance Co-Pilot PMDAMYSQL(1)