
Hi Guys Any idea what is wrong with this command?? find /home/path/* -name *.sql -exec mysql -p password -h < {} \; I am needing to import about 250 sql files. Cameron Rangeley Technical Director Phone: +64 9 970 5550 Direct: +64 9 970 5551 Mobile: +64 21 343 757 Email: cameron.rangeley(a)turnstone.co.nz <mailto:cameron.rangeley(a)turnstone.co.nz> Website: www.turnstone.co.nz <http://www.turnstone.co.nz>

Any idea what is wrong with this command??
find /home/path/* -name *.sql -exec mysql -p password -h < {} \;
I am needing to import about 250 sql files.
Try this: find /home/path/ -name "*.sql" -exec mysql -p password -h < {} \; BTW you will have to enter the password 250 times! Cheers, Peter -- Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ http://www.cs.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174

Thanks I just tried the following variations with the following results. ARGON:/home # find /path/* -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory ARGON:/home/ # find /path/ -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory ARGON:/home/ # find /path/* -exec mysql -p password -h < {} \; -bash: {}: No such file or directory Cameron Rangeley Technical Director Phone: +64 9 970 5550 Direct: +64 9 970 5551 Mobile: +64 21 343 757 Email: cameron.rangeley(a)turnstone.co.nz Website: www.turnstone.co.nz -----Original Message----- From: wlug-bounces(a)list.waikato.ac.nz [mailto:wlug-bounces(a)list.waikato.ac.nz] On Behalf Of Peter Reutemann Sent: Tuesday, 9 March 2010 4:08 p.m. To: Waikato Linux Users Group Subject: Re: [wlug] CLI help
Any idea what is wrong with this command??
find /home/path/* -name *.sql -exec mysql -p password -h < {} \;
I am needing to import about 250 sql files.
Try this: find /home/path/ -name "*.sql" -exec mysql -p password -h < {} \; BTW you will have to enter the password 250 times! Cheers, Peter -- Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ http://www.cs.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174 _______________________________________________ wlug mailing list | wlug(a)list.waikato.ac.nz Unsubscribe: http://list.waikato.ac.nz/mailman/listinfo/wlug -- This message was scanned by the Turnstone managed spam filter and is believed to be clean.

Thanks
I just tried the following variations with the following results.
ARGON:/home # find /path/* -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
Don't use a "*" in the search path. Unless you have a directory "/path" your search won't find anything. You have to use "/home/path" or, if you're already located in "/home", "path" by itself.
ARGON:/home/ # find /path/ -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
Same path problem.
ARGON:/home/ # find /path/* -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
"*" and path problem. Cheers, Peter -- Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ http://www.cs.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174

Heya Just quote the rest of the command args like this find /path/* -name "*.sql" -exec mysql "-ppassword -h <" {} \; Liz On 9 March 2010 16:19, Peter Reutemann <fracpete(a)gmail.com> wrote:
Thanks
I just tried the following variations with the following results.
ARGON:/home # find /path/* -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
Don't use a "*" in the search path. Unless you have a directory "/path" your search won't find anything. You have to use "/home/path" or, if you're already located in "/home", "path" by itself.
ARGON:/home/ # find /path/ -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
Same path problem.
ARGON:/home/ # find /path/* -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
"*" and path problem.
Cheers, Peter -- Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ http://www.cs.waikato.ac.nz/~fracpete/<http://www.cs.waikato.ac.nz/%7Efracpete/> Ph. +64 (7) 858-5174 _______________________________________________ wlug mailing list | wlug(a)list.waikato.ac.nz Unsubscribe: http://list.waikato.ac.nz/mailman/listinfo/wlug

Thanks Liz, thats exactly what I was looking for. CR Cameron Rangeley Technical Director Phone: +64 9 970 5550 Direct: +64 9 970 5551 Mobile: +64 21 343 757 Email: cameron.rangeley(a)turnstone.co.nz <mailto:cameron.rangeley(a)turnstone.co.nz> Website: www.turnstone.co.nz <http://www.turnstone.co.nz> From: wlug-bounces(a)list.waikato.ac.nz [mailto:wlug-bounces(a)list.waikato.ac.nz] On Behalf Of Liz Quilty Sent: Tuesday, 9 March 2010 4:26 p.m. To: Waikato Linux Users Group Subject: Re: [wlug] CLI help Heya Just quote the rest of the command args like this find /path/* -name "*.sql" -exec mysql "-ppassword -h <" {} \; Liz On 9 March 2010 16:19, Peter Reutemann <fracpete(a)gmail.com> wrote:
Thanks
I just tried the following variations with the following results.
ARGON:/home # find /path/* -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
Don't use a "*" in the search path. Unless you have a directory "/path" your search won't find anything. You have to use "/home/path" or, if you're already located in "/home", "path" by itself.
ARGON:/home/ # find /path/ -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
Same path problem.
ARGON:/home/ # find /path/* -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
"*" and path problem. Cheers, Peter -- Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ http://www.cs.waikato.ac.nz/~fracpete/ <http://www.cs.waikato.ac.nz/%7Efracpete/> Ph. +64 (7) 858-5174 _______________________________________________ wlug mailing list | wlug(a)list.waikato.ac.nz Unsubscribe: http://list.waikato.ac.nz/mailman/listinfo/wlug -- This message has been checked by the Turnstone managed spam filter and is believed to be clean.

Cameron Rangeley wrote:
Thanks
I just tried the following variations with the following results.
ARGON:/home # find /path/* -name "*.sql" -exec mysql -p password -h < {} \; -bash: {}: No such file or directory
You need to escape the <, or else bash parses it directly and tries to use {} \; as an input to find, which clearly makes no sense. find /path/* -name "*.sql" -exec mysql -p password -h \< {} \; This is almost, but not quite the same as the solution liz proposed - which also works in this situation, but may not elsewhere.

Some suggestions; Put *.sql in quotes otherwise if you have any .sql files in the current directory the shell will expand *.sql into a list of individual names. There's no space between -p and the password I think you can dump many consecutive sql files into a single invocation of mysql, and this is probably more efficient. -h should be followed by a hostname? Leave it off for localhost. cat `find /home/path/* -name "*.sql"` | mysql -ppassword On 9 March 2010 16:08, Peter Reutemann <fracpete(a)waikato.ac.nz> wrote:
Any idea what is wrong with this command??
find /home/path/* -name *.sql -exec mysql -p password -h < {} \;
I am needing to import about 250 sql files.
Try this:
find /home/path/ -name "*.sql" -exec mysql -p password -h < {} \;
BTW you will have to enter the password 250 times!
Cheers, Peter -- Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ http://www.cs.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174 _______________________________________________ wlug mailing list | wlug(a)list.waikato.ac.nz Unsubscribe: http://list.waikato.ac.nz/mailman/listinfo/wlug
-- Disclaimer: By sending an email to any of my addresses you are agreeing that: 1. I am by definition, "the intended recipient" 2. All information in the email is mine to do with as I see fit and make such financial profit, political mileage, or good joke as it lends itself to. 3. I may take the contents as representing the views of your company. 4. This overrides any disclaimer or statement of confidentiality that may be included on your message.
participants (6)
-
Bruce Kingsbury
-
Cameron Rangeley
-
Daniel Lawson
-
Liz Quilty
-
Peter Reutemann
-
Peter Reutemann