Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- USERNAME="SECRET"
- PASSWORD="SECRET"
- if [ "$#" -ne "2" ]
- then
- echo "call with name of database, name of dir in which the files are or file"
- exit 1
- fi
- DATABASE="$1"
- ## Single file case
- if [ -f "$2" ]
- then
- echo "Process $2"
- mysql -u$USERNAME -p$PASSWORD $DATABASE < $2
- elif [ -d "$2" ]
- then
- for i in "$2"*.sql
- do
- echo "Process $i"
- mysql -u$USERNAME -p$PASSWORD $DATABASE < $i
- if [ "$?" -ne "0" ]
- then
- echo "An error happened"
- exit 1
- fi
- ## Done i, mv to processed
- done
- echo "all done"
- else
- echo "unkown type $2"
- fi
Add Comment
Please, Sign In to add comment