Source multiple sql files with blank in name
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm actually blocking on a stupid thing ... yet i can't get it throught.
We've got a git repository on which we have our php files and our sql patch.
Every time i update my repo, i have to check if any sql patch has to be played.
To avoid searching wich one is to play, i've made a small script that give me every sql file taht my last git pull gave me:
find $MY_DIR/scripts/sandbox/migrations -type f -newermt $(date +'%Y-%m-%d') ! -newermt $(date +'%Y-%m-%d' --date="tomorrow") -not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
This gives me and output that looks like this
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.14 - script1.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28 - script2.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.15 - script3.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.12 - script4.sql
Now, i'm trying to source those files automaticaly in mysql.
I've tried doing something like this:
mysql myDataBase < $(./myStript.sh)
But i get an error message with ambiguous redirection
.
So i tried:
cat $(./myScript.sh) | mysql myDataBase
But now, the space contained in my filename path is blocking, and mysql said "no existing file" because it takes only /home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28
as filename path.
I guess i have to escape the blanks, but i'm not finding any elegant solution that works.
Update: I want to keep myScript.sh independant, so that i can steel use it in other things.
bash mysql cat
add a comment |Â
up vote
0
down vote
favorite
I'm actually blocking on a stupid thing ... yet i can't get it throught.
We've got a git repository on which we have our php files and our sql patch.
Every time i update my repo, i have to check if any sql patch has to be played.
To avoid searching wich one is to play, i've made a small script that give me every sql file taht my last git pull gave me:
find $MY_DIR/scripts/sandbox/migrations -type f -newermt $(date +'%Y-%m-%d') ! -newermt $(date +'%Y-%m-%d' --date="tomorrow") -not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
This gives me and output that looks like this
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.14 - script1.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28 - script2.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.15 - script3.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.12 - script4.sql
Now, i'm trying to source those files automaticaly in mysql.
I've tried doing something like this:
mysql myDataBase < $(./myStript.sh)
But i get an error message with ambiguous redirection
.
So i tried:
cat $(./myScript.sh) | mysql myDataBase
But now, the space contained in my filename path is blocking, and mysql said "no existing file" because it takes only /home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28
as filename path.
I guess i have to escape the blanks, but i'm not finding any elegant solution that works.
Update: I want to keep myScript.sh independant, so that i can steel use it in other things.
bash mysql cat
I think you would be better off executing the myStript.sh script and then take each line as a file path and pass it to mysql with "mysql myDataBase < $RETURNEDLINE"
â Raman Sailopal
Jan 5 at 14:38
In fact, that is litteraly what i'm trying to do...
â Carpette
Jan 5 at 14:41
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm actually blocking on a stupid thing ... yet i can't get it throught.
We've got a git repository on which we have our php files and our sql patch.
Every time i update my repo, i have to check if any sql patch has to be played.
To avoid searching wich one is to play, i've made a small script that give me every sql file taht my last git pull gave me:
find $MY_DIR/scripts/sandbox/migrations -type f -newermt $(date +'%Y-%m-%d') ! -newermt $(date +'%Y-%m-%d' --date="tomorrow") -not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
This gives me and output that looks like this
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.14 - script1.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28 - script2.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.15 - script3.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.12 - script4.sql
Now, i'm trying to source those files automaticaly in mysql.
I've tried doing something like this:
mysql myDataBase < $(./myStript.sh)
But i get an error message with ambiguous redirection
.
So i tried:
cat $(./myScript.sh) | mysql myDataBase
But now, the space contained in my filename path is blocking, and mysql said "no existing file" because it takes only /home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28
as filename path.
I guess i have to escape the blanks, but i'm not finding any elegant solution that works.
Update: I want to keep myScript.sh independant, so that i can steel use it in other things.
bash mysql cat
I'm actually blocking on a stupid thing ... yet i can't get it throught.
We've got a git repository on which we have our php files and our sql patch.
Every time i update my repo, i have to check if any sql patch has to be played.
To avoid searching wich one is to play, i've made a small script that give me every sql file taht my last git pull gave me:
find $MY_DIR/scripts/sandbox/migrations -type f -newermt $(date +'%Y-%m-%d') ! -newermt $(date +'%Y-%m-%d' --date="tomorrow") -not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
This gives me and output that looks like this
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.14 - script1.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28 - script2.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.15 - script3.sql
/home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.12.12 - script4.sql
Now, i'm trying to source those files automaticaly in mysql.
I've tried doing something like this:
mysql myDataBase < $(./myStript.sh)
But i get an error message with ambiguous redirection
.
So i tried:
cat $(./myScript.sh) | mysql myDataBase
But now, the space contained in my filename path is blocking, and mysql said "no existing file" because it takes only /home/carpette/www/myFolder/scripts/sandbox/migrations/done/2017.09.28
as filename path.
I guess i have to escape the blanks, but i'm not finding any elegant solution that works.
Update: I want to keep myScript.sh independant, so that i can steel use it in other things.
bash mysql cat
edited Jan 5 at 14:54
asked Jan 5 at 14:29
Carpette
1691212
1691212
I think you would be better off executing the myStript.sh script and then take each line as a file path and pass it to mysql with "mysql myDataBase < $RETURNEDLINE"
â Raman Sailopal
Jan 5 at 14:38
In fact, that is litteraly what i'm trying to do...
â Carpette
Jan 5 at 14:41
add a comment |Â
I think you would be better off executing the myStript.sh script and then take each line as a file path and pass it to mysql with "mysql myDataBase < $RETURNEDLINE"
â Raman Sailopal
Jan 5 at 14:38
In fact, that is litteraly what i'm trying to do...
â Carpette
Jan 5 at 14:41
I think you would be better off executing the myStript.sh script and then take each line as a file path and pass it to mysql with "mysql myDataBase < $RETURNEDLINE"
â Raman Sailopal
Jan 5 at 14:38
I think you would be better off executing the myStript.sh script and then take each line as a file path and pass it to mysql with "mysql myDataBase < $RETURNEDLINE"
â Raman Sailopal
Jan 5 at 14:38
In fact, that is litteraly what i'm trying to do...
â Carpette
Jan 5 at 14:41
In fact, that is litteraly what i'm trying to do...
â Carpette
Jan 5 at 14:41
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
./myStript.sh | while read line
do
mysql myDataBase < "$line"
done
Run the script and take the output line by line, passing the result as a file path to mysql for it to read in and process. Add quotes to the $line variable (file path) to take account of spaces.
add a comment |Â
up vote
0
down vote
Something like
find $MY_DIR/scripts/sandbox/migrations -type f
-newermt $(date +'%Y-%m-%d') !
-newermt $(date +'%Y-%m-%d' --date="tomorrow")
-not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
-exec msqlclient MyDatabase -u $USER -h $HOST -p < "" ;
Replace $USER and $HOST as appropriate
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
./myStript.sh | while read line
do
mysql myDataBase < "$line"
done
Run the script and take the output line by line, passing the result as a file path to mysql for it to read in and process. Add quotes to the $line variable (file path) to take account of spaces.
add a comment |Â
up vote
0
down vote
accepted
./myStript.sh | while read line
do
mysql myDataBase < "$line"
done
Run the script and take the output line by line, passing the result as a file path to mysql for it to read in and process. Add quotes to the $line variable (file path) to take account of spaces.
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
./myStript.sh | while read line
do
mysql myDataBase < "$line"
done
Run the script and take the output line by line, passing the result as a file path to mysql for it to read in and process. Add quotes to the $line variable (file path) to take account of spaces.
./myStript.sh | while read line
do
mysql myDataBase < "$line"
done
Run the script and take the output line by line, passing the result as a file path to mysql for it to read in and process. Add quotes to the $line variable (file path) to take account of spaces.
answered Jan 5 at 14:47
Raman Sailopal
1,18117
1,18117
add a comment |Â
add a comment |Â
up vote
0
down vote
Something like
find $MY_DIR/scripts/sandbox/migrations -type f
-newermt $(date +'%Y-%m-%d') !
-newermt $(date +'%Y-%m-%d' --date="tomorrow")
-not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
-exec msqlclient MyDatabase -u $USER -h $HOST -p < "" ;
Replace $USER and $HOST as appropriate
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
add a comment |Â
up vote
0
down vote
Something like
find $MY_DIR/scripts/sandbox/migrations -type f
-newermt $(date +'%Y-%m-%d') !
-newermt $(date +'%Y-%m-%d' --date="tomorrow")
-not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
-exec msqlclient MyDatabase -u $USER -h $HOST -p < "" ;
Replace $USER and $HOST as appropriate
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Something like
find $MY_DIR/scripts/sandbox/migrations -type f
-newermt $(date +'%Y-%m-%d') !
-newermt $(date +'%Y-%m-%d' --date="tomorrow")
-not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
-exec msqlclient MyDatabase -u $USER -h $HOST -p < "" ;
Replace $USER and $HOST as appropriate
Something like
find $MY_DIR/scripts/sandbox/migrations -type f
-newermt $(date +'%Y-%m-%d') !
-newermt $(date +'%Y-%m-%d' --date="tomorrow")
-not -path "$MY_DIR/scripts/sandbox/migrations/generated/*"
-exec msqlclient MyDatabase -u $USER -h $HOST -p < "" ;
Replace $USER and $HOST as appropriate
answered Jan 5 at 14:50
ivanivan
3,1291213
3,1291213
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
add a comment |Â
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
I might have specified that i want to keep both treatment independants. I update my question
â Carpette
Jan 5 at 14:53
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f414996%2fsource-multiple-sql-files-with-blank-in-name%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I think you would be better off executing the myStript.sh script and then take each line as a file path and pass it to mysql with "mysql myDataBase < $RETURNEDLINE"
â Raman Sailopal
Jan 5 at 14:38
In fact, that is litteraly what i'm trying to do...
â Carpette
Jan 5 at 14:41