Solved

Bash database programming?

Posted on 2004-08-02
11
1,905 Views
Last Modified: 2008-01-09
i want to make a student record database in bash programming in which i have the facility to search,edit existing record,deleting a existing record or add a particular record and any other extra
option that can be handled. what should be the code i am just a beginner in bash programming , how i handle the user input on a particulat key or like that , what would be the code shape,
is there sample bash programming database sample codes like this are online? waiting for your replies...
0
Comment
Question by:baburkhan
  • 4
  • 4
  • 3
11 Comments
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 11692548
If it was me, I would use perl rather than bash. http://www.tldp.org/LDP/abs/html/ is a great bash guide with a lot of sample code.
0
 
LVL 20

Expert Comment

by:Gns
ID: 11693961
CC foot. Definitely simpler in perl;).

What type of "database" would that be? Are we thinking "flat file", dbm, "ISAM-ish" (berkeley DB perhaps) or RDBMS (MySQL, PostgreSQL or the like)?
Some of the above would not really be possible in "pure bash", but would need some kind of interpreter or like... psql for posgresql etc.
But perhaps it would be a flat file, in which case you'd rely heavily on diverse text/file utilities.

Is this a school assignment?

-- Glenn
0
 

Author Comment

by:baburkhan
ID: 11703641
ya it would be good to use pear , it would be a flat file for database in bash programming. But i dont know anything about pearl, can you people help me. But please can your tell me the sample databases in both pearl and bash , that would be easier for me.
it is not a school assignment it is related to my job. i have just started programming in Linux, otherwise i would have used SQL and VB.net in windows.
0
 
LVL 20

Expert Comment

by:Gns
ID: 11706186
Ok... Working with a flat file is possibly, but... It'd be very cumbersome, be susceptible to file-locking issues and scale really badly.
Might one suggest that you go with either MySQL (http://www.mysql.com) or PostgreSQL (http://www.postgresql.org/) as your database (MySQL is perhaps a tad faster, while PostgreSQL (at least used to) boast the best stabdards compliance. I've used both and find them very good in different respect... Little things mostly:).
That way you could build your database in a somewhat familiar SQL environment, and have a choice... use commandline tools like mysql or psql (a bit like Oracles sqlplus tool), access it from perl via the DBD abstraction (after overcomming the hurdle of teaching yourself perl... might be a steep learning curve:), access it in a web context via simple PHP (which would perhaps most look'n'feel like VB... Look at http://www.php.net)... which would give you a consisten and easily deployable user interface, or use tools like kdevelop to build your GUI app (in this case for KDE)... The choices are endless, and depend on factors like how you plan to deply the app, who the target group is etc etc.

-- Glenn
0
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 11710154
Depending on how many students you are catering for, http://www.dplace.com/cardfile/ is a great flatfile database program. You can setup your own database with the fields you specify. IE in this case, student DOB,subjects,exam results etc. You can search on any field, use any field as an index etc. Why reinvent the wheel?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:baburkhan
ID: 11749936
so cant anyone tell me the script programmnig in  bash for database of students? is there no work done on it? is there no example on it?
0
 

Author Comment

by:baburkhan
ID: 11749938
is there any example database in bash programming?
0
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 11756982
" is there any example database in bash programming?"

Why does it have to be in bash? Why do the programming work when  programs like the one I suggested above have already been written and will run a lot quicker because they have been written in C?
0
 
LVL 20

Expert Comment

by:Gns
ID: 11760617
I'm guessing baburkhan is expecting us to do his homework for him, sort of:-). Since we're not allowed to do that, we won't;-).
What we will do is (of course) to point to likely resources (information, perhaps some example code, or (as in your case foot) fully functional opensource implementations) and comment on code (if any is shown)...
I'm sure there are "examples" like what is asked for, but nothing that comes readily to mind.
(I could also add ... Why not take one of the nice "alternatives" I and foot mention, and start asking from that? Since you don't baburkhan, it seems you have "requirements" you haven't mentioned to us;).

-- Glenn
0
 

Author Comment

by:baburkhan
ID: 11771695
Firslty, it is not some type of homework or so that you are guessing, if you are in job and your administrator has said you to work or complete the work according to his requirement how can we neglect that?????
if i asked you some bash programming database why are you trying to point that it is some sort of homework?
Secondly i am not good in using linux though i have used windows a lot, so if that would be in windows i had sed sql or access but i dont know how to use mysql in linux so i preffered bash as i have did some work in bash programming but never made a database.if i start leaning perl that will be taking much more time.
that why i was asking the database in bash programming.
0
 
LVL 20

Accepted Solution

by:
Gns earned 175 total points
ID: 11773683
> Firslty, it is not some type of homework or so that you are guessing, if you are in job and your administrator has said you to work or complete the work according to his
> requirement how can we neglect that?????
Cool.

> if i asked you some bash programming database why are you trying to point that it is some sort of homework?
We've given you a lot of "examples" to choose from, and expected you to do so, but you seemed to be stuck on bash (which, although a great scripting tool isn't perhaps the greatest tool for doing UIs and stuff) lead the thought to there being "something" we don't know about in form of requirement or prerequisite ... And this "something" is often school assignments (stipulating rather arbitrary limits:-). So the guess isn't so farfetched as it may seem. Anyway, we'll take your word for it, and try helpas best we can.

> Secondly i am not good in using linux though i have used windows a lot, so if that would be in windows i had sed sql or access but i dont know how to use mysql in linux
> so i preffered bash as i have did some work in bash programming but never made a database.if i start leaning perl that will be taking much more time.
> that why i was asking the database in bash programming.
Ok, really no problem with your reasoning.
Might one suggest that you do have a look at PHP in conjunction with either PostgreSQL or MySQL, and a webbased solution? I really think you'll find this to be the easiest path to success... There are numerous open source projects based around that, so it wouldn't be hard to find example code/scripts that are freely available.

And the database... setting up a database is generally not difficult, and the DBMS would handle your data in a consistent and safe way while you still would have the familiarity of the SQL languague to fall back on...

You could use the mysql or psql in a bash script envelope, and you could use dialog (or similar tools) to build your CUI in a nice way (menus, buttons and such)...
Or make a very plain "menu" system somewhat like
while true
do
  echo "1. choice 1"
  echo "2. choice 2"
...
  echo "0. Exit"
  read choice
  case $choice in
    1) echo "sql statements" | psql -u user -p passwd database ;;
    2) echo "other sql statements" | psql -u user -p passwd database ;;
    0) exit ;;
    *) ;;
  esac
done
.... or something like that... Rather cumbersome way to build an UI:-).

-- Glenn
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now