RE: Parameter passing on shell script

2002-03-25 Thread Gurhan Ozen

Hi Oswaldo..
You have the parameter inside the sql file , not in the script itself.
Try this:

#!/bin/bash

QUERY=load data infile '/home/loader/txt/file_${date_proc}.txt into table
debits
fields terminated by ';'

mysql -u user -ppass -D dbname -e $QUERY



Gurhan


-Original Message-
From: Oswaldo Castro [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 9:39 AM
To: [EMAIL PROTECTED]
Subject: Parameter passing on shell script


Hi List

I'm new to MySQL and I need help on how to pass shell parameter to a mysql
script file (bash/SuSE 7.2)

I have one file called run_db_load and I called it from the command line as

# date_proc=25032002

# export date_proc

# ./run_db_load $date_proc



Inside the run_db_load file I have:

mysql -u user -ppass dbname  file_to_load.sql



Inside the file_to_load.sql I need to capture the $date_proc variable, so
its content is:

load data infile '/home/loader/txt/file_${date_proc}.txt into table debits
fields terminated by ';'



The problem is that the ${date_proc} doesn't get substituted and MySQL give
an error.

Any help will be very appreciated

Thanks in advance

Oswaldo Castro




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Parameter passing on shell script

2002-03-25 Thread Gerald Clark

Try:

echo 
load data infile '/home/loader/txt/file_${date_proc}.txt' into table debits
fields terminated by ';'
 | mysql -u user -ppass dbname 



Oswaldo Castro wrote:

Hi List

I'm new to MySQL and I need help on how to pass shell parameter to a mysql
script file (bash/SuSE 7.2)

I have one file called run_db_load and I called it from the command line as

# date_proc=25032002

# export date_proc

# ./run_db_load $date_proc



Inside the run_db_load file I have:

mysql -u user -ppass dbname  file_to_load.sql



Inside the file_to_load.sql I need to capture the $date_proc variable, so
its content is:

load data infile '/home/loader/txt/file_${date_proc}.txt into table debits
fields terminated by ';'



The problem is that the ${date_proc} doesn't get substituted and MySQL give
an error.

Any help will be very appreciated

Thanks in advance

Oswaldo Castro




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail 
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php





-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php