Parameterised Call to MySQL


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parameterised Call to MySQL
# 1  
Old 03-30-2009
Parameterised Call to MySQL

Hi,

I am trying to do a mysql insert from a script, using a parameter which holds a value taken from a filename. I must be missing something as the param is not holding any value.

Any suggestions please; (input files will look like aaa.123.dat)

#/bin/bash
# 30th March 2008

for filename in *.dat
do

set PARAM1 = `echo - $filename | cut -d'.' -f1`
set PARAM2 = `echo - $filename | cut -d'.' -f2`
set PARAM3 = `echo - $filename | cut -d'.' -f3`
done
mysql -u root -pPassword -h??.???.???.??? database_name -e "insert into test (test_field) values ($PARAM2)"
# 2  
Old 03-30-2009
sorted, format issue

set PARAM1 = `echo - $filename | cut -d'.' -f1`

now reads

PARAM1=`echo $filename | cut -d'.' -f1`
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

MySQL Daemon failed to start - no mysql.sock file

After doing a yum install mysql mysql-server on Fedora 14 I wasn't able to fully install the packages correctly. It installed MySQL 5.1. I was getting the following error when running the: mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)... (3 Replies)
Discussion started by: jastanle84
3 Replies

2. Shell Programming and Scripting

Call Shell Function from mysql timestamp

Hi all, Actually my aim is to call the shell script when ever there is a hit in a mysql table which consist of 3 values. Acter some research I came to know that it is not possible and can achive with timestamp. Can someone please tell me how to read the table timestamp which should done... (3 Replies)
Discussion started by: santhoshvkumar
3 Replies

3. Shell Programming and Scripting

How to create and call mysql stored procedure in perl?

Hi, I want to create MySQL stored procedure and call the stored procedure using perl. I tried like this: use DBI; my $dbh = DBI->connect ("DBI:mysql:test", "root", "ibab", { RaiseError => 1, PrintError => 0}); $create_procedure =... (5 Replies)
Discussion started by: vanitham
5 Replies

4. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

5. Shell Programming and Scripting

parameterised functions

Hi, Can anybody tell me how to create a function with parameters in a shell script. cheers RRK (2 Replies)
Discussion started by: ravi raj kumar
2 Replies

6. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies
Login or Register to Ask a Question