Guest User

Untitled

a guest
Nov 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. USERNAME="SECRET"
  4. PASSWORD="SECRET"
  5.  
  6. if [ "$#" -ne "2" ]
  7. then
  8. echo "call with name of database, name of dir in which the files are or file"
  9. exit 1
  10. fi
  11.  
  12. DATABASE="$1"
  13.  
  14. ## Single file case
  15. if [ -f "$2" ]
  16. then
  17. echo "Process $2"
  18. mysql -u$USERNAME -p$PASSWORD $DATABASE < $2
  19.  
  20. elif [ -d "$2" ]
  21. then
  22. for i in "$2"*.sql
  23. do
  24. echo "Process $i"
  25. mysql -u$USERNAME -p$PASSWORD $DATABASE < $i
  26.  
  27. if [ "$?" -ne "0" ]
  28. then
  29. echo "An error happened"
  30. exit 1
  31. fi
  32.  
  33. ## Done i, mv to processed
  34. done
  35. echo "all done"
  36.  
  37. else
  38. echo "unkown type $2"
  39.  
  40. fi
Add Comment
Please, Sign In to add comment