Storing information into a database.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Storing information into a database.
# 1  
Old 01-07-2010
Storing information into a database.

Hey guys, i am having a problem in storing new data into a text file.

The database in in a text file and it displays information like this :

Name : Price : Quantity
Persia : 80 : 30

Now , i have written the code to check if the book already exist in the Databse.

Code:
Number=
echo -n "Title : "
read number
if grep -q "$number" Hello1  ; then
echo "hello"
fi
}

If the book does not exist , how do i go about to getting it to store inside the database?
# 2  
Old 01-07-2010
Code:
Number=
echo -n "Title : "
read number
if grep -q "$number" Hello1  ; then
echo "hello"
else
echo Not found
echo "title: \c"
read title
echo "Price: \c"
read price
echo "Quantity: \c"
read quantity
echo $title $price $quantity >>database
fi

}


Last edited by Scott; 01-07-2010 at 02:55 PM.. Reason: Added code tags
# 3  
Old 01-07-2010
thanks a lot. i would like to ask.
Code:
echo $title $price $quantity >>database

why is there a need to put echo at the front. i thought it was only used to display an output?
# 4  
Old 01-07-2010
That is true, but you are redirecting the output to the database file, rather than standard output. And note that there are two >>, meaning that the line is appended to the end of the current file.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CRON Job to copy database and replace existing database

I have a reseller account with hostgator, which means i have WHM and Cpanel. I have set up a staging environment for one of my wordpress installations (client website), which is essentially sitting at staging.domain.com (live site is at domain.com). The staging website is a complete copy of the... (1 Reply)
Discussion started by: nzrobert
1 Replies

2. Solaris

Can't create database after Oracle Database installation

I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options. OPERATION_TYPE = "createDatabase" GDBNAME = "solaris_user.domain.com" SID = "solaris_user" TEMPLATENAME = "General... (0 Replies)
Discussion started by: solaris_user
0 Replies

3. Solaris

redirect solaris database from linux database..

hi.. i have a need .. my php runs on my linux redhat box with mysql.. i want my php code to refer another mysql database which is in solaris 10 x86... can u tell me the procedure .. how it can be done through php .. sorry am new to php... is it possible to redirect from linux mysql to... (7 Replies)
Discussion started by: senkerth
7 Replies

4. UNIX for Dummies Questions & Answers

Need information on Database in "Unix"

How can I find which database is installed in my Unix server ? (5 Replies)
Discussion started by: kukkaster
5 Replies

5. Shell Programming and Scripting

About storing the value of wc -l into a variable and then using this value in while

Hi all, I m new to this forum. I ma facing onei issue. I have something like this: length= wc -l < b2| awk '{print $1}' where b2 is filename having detauls like: cat b2 abc1 abc4 xyc3 sbdghf4 but when I do echo "$length" it displays nothing Also I am using awk to overcome... (4 Replies)
Discussion started by: student2009
4 Replies

6. Shell Programming and Scripting

Storing information in arrays....

Hello, I am writing a shell script to do the following. It greps information from the messages log and then I use the cut command to isolate the field I need (the username) and output the information to a text file. I now have to do the following. Count how many times each user logged in. So... (3 Replies)
Discussion started by: mojoman
3 Replies

7. Shell Programming and Scripting

A script pls( To retrieve database information)

KSH - Unix -AIX - db2 ************** Get the input from the user say '123' (It varies) Then i want to connect to a database say "D1" then i want th extract from the database by giving "select * from tablename where input = '123' I also want to connect to another database "D2" then i... (3 Replies)
Discussion started by: rollthecoin
3 Replies

8. Shell Programming and Scripting

storing database query in a variable

I am executing a SQL query in Unix Server: select status,location from user_information where request_id='DS-43720' In shell script I am writing this query in the below manner: echo "select status,location from user_information where request_id='DS-43720' ;" >> $directory/info.sql ... (3 Replies)
Discussion started by: debu
3 Replies

9. Programming

SunWS_cache: Information: Database is locked, waiting

While compiling a set of proC code I am getting the following error. Any clues why this error is coming and is it related to my Oracle DB/Verison Software DB or compile time generated information? Thanks Rishi (3 Replies)
Discussion started by: RishiPahuja
3 Replies
Login or Register to Ask a Question