Solved

Shell Scripting

Posted on 2002-03-28
8
306 Views
Last Modified: 2013-11-13
hi guys,
I am doing a program in shell scripting which should automcatically install the jdk,mysql. Before installing it should search whether it has been installed already. Please guide me regarding this.

Regards,
Sujatha
0
Comment
Question by:sujatharathinam
8 Comments
 
LVL 17

Expert Comment

by:dorward
ID: 6906070
THIS = `which ASDF`;  ; if [ "$THIS" == "" ]; then echo "Install ASDF, this could be the command that installs it rather than an echo"; else echo "Already installed"; fi

Where ASDF is the name of a binary file that will be in the users path if the relevent package is installed (e.g. javac, mysql)
0
 

Author Comment

by:sujatharathinam
ID: 6906522
hi dorward,
I can't check $THIS="", because if javac or mysql is not installed then my console will throw an error and by default it is not going to be empty, as it contain error values. So suggest a solution for the same.
Regards,
Sujatha
0
 
LVL 17

Expert Comment

by:dorward
ID: 6906721
david@cyberman:david]which wibble
david@cyberman:david]


Are you sure? Or perhaps there are different versions of which out there.

Assuming any errors go to STDERR use instead:
which filename 2> /dev/null

And you can use any variable name you like, it doesn't have to be THIS.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 6908538
which is unreliable for the questioner's purpose, as is any package checking

You need to know the executable (and libraries) in question, then you can search for with find, like:

   find / -type f -name mysql
0
 

Expert Comment

by:0xDEADBEEF
ID: 6917639
'find' will take a whole lot of time... Anyway, this is unreliable as well. I guess you want to install the JDK 1.4.0 (Java 2). Imagine the user has got the JDK 1.1.8 (Java 1, deprecated) installed on his computer.
The 'find / -name javac' or 'which javac 2> /dev/null' will find the JDK 1.1.8 and therefore your script will not install the JDK 1.4.0, although you want it to.

Now, I would rather use rpm. It should be possible to obtain rpm packages of mysql and the JDK (I think the JDK always comes as rpm package), and your script might look like this:

#! /bin/sh

rpm -vv -i j2sdk-1.4.0.rpm
rpm -vv -i mysql.rpm

#The -i option tells rpm to install the package, in case
#it is not yet installed, the -vv option makes it show what
#it does exactly. The packages may be named differently.

Have a look at the rpm manpage for more detailed information.

Hope this helps.
0
 
LVL 17

Expert Comment

by:dorward
ID: 6918325
rpm is also very unreliable, not all users will have installed the JDK using the RPM, and not everybody uses an RPM based system.
0
 

Expert Comment

by:SpideyMod
ID: 8021464
sujatharathinam,
You have already been asked to clean up your opened questions.  I will give you 3 days to maintain these open questions before I ask administration to suspend your account.  I have provided easy links to your questions below.  You must take care of each opened question by the time I return. I will be posting this in each of your opened questions.  If you need help with deletions, post a commnet in your question if experts have replied indicating your desire to delete, then post a question in community support and list the questions: http://www.experts-exchange.com/Community_Support/

I am leaving this question opened until the 3 day period expires.  It is on a new cleanup list.

SpideyMod
Community Support Moderator @Experts Exchange

DO NOT ACCEPT THIS COMMENT AS AN ANSWER.

Questions Asked
20
Last 10 Grades Given
A A B B A A B A A A
Question Grading Record
10 Answers Graded / 10 Answers Received

http://www.experts-exchange.com/Operating_Systems/Linux/Q_20282856.html
http://www.experts-exchange.com/Databases/Oracle/Q_20330448.html
http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_20495382.html
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20488726.html
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20326321.html
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20292542.html
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20292539.html
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20270570.html
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20150319.html
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20179283.html
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8048491
PAQ'd and points not refunded.

SpideyMod
Community Support Moderator @Experts Exchange

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

821 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