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
CGI::Session::Driver::mysql(3pm)			User Contributed Perl Documentation			  CGI::Session::Driver::mysql(3pm)

NAME
CGI::Session::Driver::mysql - CGI::Session driver for MySQL database SYNOPSIS
$s = CGI::Session->new( 'driver:mysql', $sid); $s = CGI::Session->new( 'driver:mysql', $sid, { DataSource => 'dbi:mysql:test', User => 'sherzodr', Password => 'hello' }); $s = CGI::Session->new( 'driver:mysql', $sid, { Handle => $dbh } ); DESCRIPTION
mysql stores session records in a MySQL table. For details see CGI::Session::Driver::DBI, its parent class. It's especially important for the MySQL driver that the session ID column be defined as a primary key, or at least "unique", like this: CREATE TABLE sessions ( id CHAR(32) NOT NULL PRIMARY KEY, a_session TEXT NOT NULL ); To use different column names, change the 'create table' statement, and then simply do this: $s = CGI::Session->new('driver:mysql', undef, { TableName=>'session', IdColName=>'my_id', DataColName=>'my_data', DataSource=>'dbi:mysql:project', }); or $s = CGI::Session->new('driver:mysql', undef, { TableName=>'session', IdColName=>'my_id', DataColName=>'my_data', Handle=>$dbh, }); DRIVER ARGUMENTS mysql driver supports all the arguments documented in CGI::Session::Driver::DBI. In addition, DataSource argument can optionally leave leading "dbi:mysql:" string out: $s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'shopping_cart'}); # is the same as: $s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'dbi:mysql:shopping_cart'}); BACKWARDS COMPATIBILITY As of V 4.30, the global variable $CGI::Session::MySQL::TABLE_NAME cannot be used to set the session table's name. This is due to changes in CGI::Session::Driver's new() method, which now allows the table's name to be changed (as well as allowing both the 'id' column name and the 'a_session' column name to be changed). See the documentation for CGI::Session::Driver::DBI for details. In particular, the new syntax for "new()" applies to all database drivers, whereas the old - and bad - global variable method only applied to MySQL. Alternately, call $session -> table_name('new_name') just after creating the session object if you wish to change the session table's name. LICENSING
For support and licensing see CGI::Session. perl v5.12.4 2011-07-08 CGI::Session::Driver::mysql(3pm)