LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-28-2017, 09:26 AM   #1
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Rep: Reputation: 15
Shell script to traverse folders and deploy sql files


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.
Attached Files
File Type: txt Script.txt (686 Bytes, 77 views)
 
Old 11-28-2017, 10:20 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 23,950

Rep: Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029Reputation: 7029
Quote:
Originally Posted by zaeem View Post
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.
 
Old 11-28-2017, 10:22 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,636

Rep: Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614
also you may try to insert set -xv at the beginning of your script to see what's happening
 
Old 11-28-2017, 10:28 AM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-30
Posts: 5,290

Rep: Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916
this line is fubar:
Code:
                        /usr/bin/mysql --login-path=local --comments TestDB -f < $filename || exit 0;
because $filename is a directory.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Creating folders and moving files in shell script Asoo Linux - Newbie 2 05-24-2017 07:48 AM
Using rm in Bash shell script on files/folders with spaces in for loop array kayasaman Programming 18 05-16-2013 06:34 AM
[SOLVED] executing .sql files in shell script smritisingh03 Linux - Newbie 6 11-24-2010 10:23 AM
Shell script to delete folders and files dynamically and recursively rjbaca Linux - General 1 06-21-2010 11:26 AM
Bourne shell script traverse kdyzsa Programming 4 05-06-2008 07:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration