Advertisement
metalx1000

SQLite Example Shell Script

Feb 3rd, 2019
1,187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. db="example2.db"
  4. table="people"
  5.  
  6. echo "===Welcome==="
  7. echo "Please Enter User Info"
  8.  
  9. while [ 1 ]
  10. do
  11.   echo -n "First Name: "
  12.   read fname
  13.   if [ "$fname" = "" ];then echo "Value Needed";exit 1;fi
  14.  
  15.   echo -n "Last Name: "
  16.   read lname
  17.   if [ "$lname" = "" ];then echo "Value Needed";exit 1;fi
  18.  
  19.   echo -n "Phone Number: "
  20.   read phone
  21.   if [ "$phone" = "" ];then echo "Value Needed";exit 1;fi
  22.  
  23.   sqlite3 "$db" "INSERT INTO $table VALUES ('$fname','$lname','$phone')"&& echo "$fname Entered" || echo "ERROR"
  24.  
  25.   echo -n "Would you like to enter another user? (Y/n): "
  26.   read ans
  27.  
  28.   if [ "$ans" = "n" ]
  29.   then
  30.     echo "Goodbye..."
  31.     exit 0
  32.   else
  33.     clear
  34.   fi
  35. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement