LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script to traverse folders and deploy sql files (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-to-traverse-folders-and-deploy-sql-files-4175618539/)

zaeem 11-28-2017 09:26 AM

Shell script to traverse folders and deploy sql files
 
1 Attachment(s)
I need to write a bash script which can traverse directories and sub-directories and deploy SQL files to MySQL database. I have written script (attached as script.sh) which is giving error "ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.". Please let me know how to avoid this error and deploy only *.SQL files.

TB0ne 11-28-2017 10:20 AM

Quote:

Originally Posted by zaeem (Post 5786210)
I need to write a bash script which can traverse directories and sub-directories and deploy SQL files to MySQL database. I have written script (attached as script.sh) which is giving error "ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.". Please let me know how to avoid this error and deploy only *.SQL files.

Please post your code in CODE tags and not as attachments. Also, you've been a member here for seven years, and have been asking about scripts for at least six. Doing a recursive find in a script is something you've done before:
https://www.linuxquestions.org/quest...-files-879692/

As before, have you done ANY debugging on your script? The bash scripting beginners guide has steps on how to debug bash shell scripts:
http://tldp.org/LDP/Bash-Beginners-G...ect_02_03.html

Start there.

pan64 11-28-2017 10:22 AM

also you may try to insert set -xv at the beginning of your script to see what's happening

schneidz 11-28-2017 10:28 AM

this line is fubar:
Code:

                        /usr/bin/mysql --login-path=local --comments TestDB -f < $filename || exit 0;
because $filename is a directory.


All times are GMT -5. The time now is 07:10 AM.