Solved

Shell Scripting

Posted on 2002-03-28
8
307 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
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.

739 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