Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Shell Scripting

Posted on 2002-03-28
8
Medium Priority
?
316 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

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…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

971 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