Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BASH Scripting Help Needed: Scripting MySQL
#1
I'm here once again to consult the great knowledge present.

I'm working on writing a web app thingy, and would like to input stuff into a database, it has to be by hand and I'd like to be able to do it easily and quickly. Currently my code is:


#!/bin/bash

#Ask if you are in enter mode. -e By the way

if
[ "$1" == -e ] ; then

echo "Hello, welcome to Life."
echo --------------------------
echo "You have chosen to enter information into the database."
echo "-------------------------"
echo -n "Please enter the title of the information --> "
read $title
echo "Please enter the description: "
read $description
echo -n "Please enter the type --> "
read $type
echo "Please enter the location"
read $location
echo "Please enter any notes"
read $notes
echo "Please enter the physical location if it applies"
read $physlocation
echo "Please enter any keywords you would like associated with this item."
read $keywords


/Applications/MAMP/Library/bin/mysql --user=microchip -p Life --execute=< "INSERT INTO `items` ( `title` , `description` , `type` , `keywords` , `location` , `notes` , `physlocation` )
VALUES (
'$title', '$description', '$type', '$keywords', '$location', '$notes', '$physlocation'
);"
EOF

else

echo "That's not valid"

fi


What I get is:

./Life.sh: line 1: items: command not found
./Life.sh: line 1: title: command not found
./Life.sh: line 1: description: command not found
./Life.sh: line 1: keywords: command not found
./Life.sh: line 1: location: command not found
./Life.sh: line 1: notes: command not found
./Life.sh: line 1: physlocation: command not found
/Applications/MAMP/Library/bin/mysql: ambiguous option '--p' (pager, protocol)


Meaning it's trying to execute the stuff in the backtics. I've tried putting \ infront of all the backticks but there's no luck there.

Advice?

TiA!
Reply


Messages In This Thread
BASH Scripting Help Needed: Scripting MySQL - by microchip13 - 03-12-2007, 04:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)