?
Solved

Shell Scripting

Posted on 2002-03-28
8
Medium Priority
?
313 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
[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
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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
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

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

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

I have been scripting applications way too long and can never remember how to create an ISS file.  So I decided to write this article to act as my own knowledge base for future reference, and hope you will also benefit. An ISS file is a response …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

719 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