?
Solved

Bash database programming?

Posted on 2004-08-02
11
Medium Priority
?
1,935 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 700 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

650 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