Guest User

Untitled

a guest
Apr 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. echo "Input database name"
  4. read databaseName
  5. echo "The database name is set to $databaseName"
  6.  
  7. echo "Input database host"
  8. read databaseHost
  9. echo "The database host is set to $databaseHost"
  10.  
  11. echo "Input database user"
  12. read user
  13. echo "The database user is set to $user"
  14.  
  15. stty -echo
  16. echo "Input database user password"
  17. read password
  18. stty echo
  19.  
  20. echo "Input url to search for"
  21. read searchUrl
  22. echo "The search url is set to $searchUrl"
  23.  
  24. echo "Input url to replace with the searched url"
  25. read replaceUrl
  26. echo "The replace url is set to $replaceUrl"
  27.  
  28. mysql --user="$user" --password="$password" --host="$databaseHost" --database="$databaseName" -e "UPDATE messages SET message = REPLACE(message, '$searchUrl', '$replaceUrl')"
  29.  
  30. read -p "Database name: " databaseName
  31.  
  32. read -s -p "Database user: " password
  33.  
  34. command=$(printf 'UPDATE messages SET message = REPLACE(message, %q, %q')
  35. "$searchUrl", "$replaceUrl")
  36.  
  37. mysql --user="$user" --password
  38. --host="$databaseHost" --database="$databaseName"
  39. -e "$command"
  40.  
  41. read -p "Input url to search for" searchUrl;
  42. read -p "Input url to replace with the searched url" replaceUrl;
  43. mysql --user="$user" --password --host="$databaseHost" --database="$databaseName"
  44. -e "PREPARE statement FROM 'UPDATE messages SET message = REPLACE(message, ?, ?)'; EXECUTE statement USING '$searchUrl','$replaceUrl';"
Add Comment
Please, Sign In to add comment