Solved

Shell Scripting

Posted on 2002-03-28
8
304 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:0xDEADBEEF
Comment Utility
'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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQ'd and points not refunded.

SpideyMod
Community Support Moderator @Experts Exchange

0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now