Shell script to find weblogic home directory


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to find weblogic home directory
# 1  
Shell script to find weblogic home directory

Hi,

I am trying to find the weblogic home directory whether it is installed in the Linux box. if it is existing display the weblogic home and the corresponding Java home directory else display message as that wl home does not exist. I already wrote a program but it was not working properly.
Please help me

Code:
#!/bin/ksh
WL_LOCATION=`find / -name wlserver_*`
if [-d $WL_LOCATION ] then
echo "WL_HOME ......... $WL_LOCATION"
cd $WL_LOCATION/common/bin
echo `pwd`
echo `sed s/\"//g grep JAVA_HOME commEnv.sh | grep jdk`
else echo "WL Home does not exists ...."
fi

Regards,
Spgreddy

---------- Post updated at 02:07 AM ---------- Previous update was at 12:21 AM ----------

Hi

I modified the script as shown below.

Code:
#!/bin/ksh
WL_LOCATION=`find / -name wlserver_*`
echo " $WL_LOCATION"
if [! -d $WL_LOCATION]; then
        echo "WL HOME does not exists ..." exit 1
        exit 1
else {
        echo "WL_HOME ......... $WL_LOCATION"
        cd $WL_LOCATION/common/bin
        echo `grep JAVA_HOME commEnv.sh | grep jdk|sed 's/"//g'`
      }
fi

when I execute, the below is the output.

Code:
/u01/app/oracle/Middleware/wlserver_10.3
./test1.sh[5]: [!: not found [No such file or directory]
WL_HOME ......... /u01/app/oracle/Middleware/wlserver_10.3
JAVA_HOME=/u01/app/jdk1.6.0_02


But here I am not able to understand that why it shows like this even it provides the actual output.
Code:
./test1.sh[5]: [!: not found [No such file or directory]


Please help us how to over come this?

Last edited by radoulov; 09-12-2014 at 06:44 AM.. Reason: Add CODE tags.
# 2  
There are several things that look strange in your script and I'm sure it isn't doing what you are trying to do. There are missing quotes, missing seicolons, extraneous echoes, unnecessary command substitutions, and I have no idea what the sed command is trying to do. But, since I don't know where weblogic might be installed on your server, I can't guess at what you are trying to do.

Is there a user named weblogic on your server?

After looking at every file on your system, are you sure that there will be exactly one file with a name starting with the characters wlserver_? Are there any constraints on where that one file could be located?

Please describe in English the logic behind each step in your script so we can help you modify your code to fix any problems you are running into.
# 3  
Hi Don,

Thank you for your support. Forget above script currently I am looking a shell script by reading the string (/u01/app/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar) and display required output as shown below

/u01/app/oracle/Middleware/wlserver_10.3

Please help us to resolve this

Regards,
Spgreddy
# 4  
Quote:
Originally Posted by spgreddy
Hi Don,

Thank you for your support. Forget above script currently I am looking a shell script by reading the string (/u01/app/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar) and display required output as shown below

/u01/app/oracle/Middleware/wlserver_10.3

Please help us to resolve this

Regards,
Spgreddy
I can't figure out what this means. Does the string you are reading contain parentheses as shown? Is this string in a file? Is this string in a shell variable?

How is your script supposed to know what part of the string is the part you want to return? Are you trying to remove the last three components of the pathname stored in the string? Are you trying to remove all components of the pathname after the component that starts with wlserver? Are you trying to remove all components from the pathname stored in the string after the component that ends with a decimal digit? Are you trying to remove the 6th / and everything that follows it from your string?

What shell are you using? What OS are you using?
# 5  
Hi DOn
The string contains /u01/app/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar

For example :
Code:
x=/u01/app/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar

i am trying to remove the last three componets /server/lib/weblogic.jar
and want to display the output as /u01/app/oracle/Middleware/wlserver_10.3

currently i am using bash sheel in redhat linux 5

Regards,
Spgreddy

Last edited by Don Cragun; 09-12-2014 at 03:21 AM.. Reason: Add CODE and ICODE tags.
# 6  
So try something like:
Code:
#!/bin/bash
x=/u01/app/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar
y=${x%/*/*/*}
printf 'x is %s\ny is %s\n' "$x" "$y"

which produces:
Code:
x is /u01/app/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar
y is /u01/app/oracle/Middleware/wlserver_10.3

This User Gave Thanks to Don Cragun For This Post:
# 7  
Hi Don,

I have one more issue. A variable contains value like this

Code:
jhome=JAVA_HOME=/u01/app/jdk1.6.0_02

now I want output as
Code:
jhome=/u01/app/jdk1.6.0_02

please help me how can I write shell script for this

Regards,
Spgreddy

Last edited by radoulov; 09-12-2014 at 06:44 AM..
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #802
Difficulty: Medium
The CSS @font-face rule is not supported across the main browsers, Internet Explorer, Firefox, Opera, Chrome, and Safari.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to find if any new entry in directory

I require a shell script to find if any new entry of dump files present in a particular directory and to send an email if any new entry exists.I had a crontab to run the script for every 5 min. Below are the file names.dump.20150327.152407.12058630.0002.phd.gz... (9 Replies)
Discussion started by: bhas85
9 Replies

2. Shell Programming and Scripting

Need to find recursively all shell script in the /xyz directory

Pls. advise how to find or used grep recursively all shell script files. Some files doesnt have a .sh or .ksh extension name. find / -name "*" |xargs grep bin |grep sh ?? TIA (1 Reply)
Discussion started by: budz26
1 Replies

3. UNIX for Dummies Questions & Answers

How to find server that hosts my home directory?

At work I have two sets of systems, my Primary network and Secondary network. Each consists of 4 servers, 3 of them for doing work (Idaho, Omaha, Juno) and hosting the processes we work on and 1 holds all the home directories (Sword). So Idaho, Omaha and Juno use Sword for home directories (user... (7 Replies)
Discussion started by: wha72
7 Replies

4. Shell Programming and Scripting

Get the STATE of the weblogic instances via shell script.

Can I get the STATE(instance are RUNNING or not and HEALTH is OK or not) of the weblogic instances(Admin and Managed) running on my unix machine via shell script. Someone told me that it can be done via "weblogic.Admin GETSTATE"....but it is not working for me(might be I am doing something wrong)... (2 Replies)
Discussion started by: joshilalit2004
2 Replies

5. Solaris

find home directory paths for all users

How to find al the user's home directories? (2 Replies)
Discussion started by: a2156z
2 Replies

6. Shell Programming and Scripting

Find recently updated files in home directory

Is there a shell command that will allow me to list index files in the /home directory for all users on a server that have been updated within the past 24 hours? (e.g. index.htm .html .php in/home/user1/public_html /home/user2/public_html /home/user3/public_html etc ) (2 Replies)
Discussion started by: Kain
2 Replies

7. Shell Programming and Scripting

how to find out the home directory of a user??

Hi all, I would like to know how to find out the home directory of a particular user.. eg, If am the root , then my Home directory will be / if say am just a user logging into the terminal then my home dir would change, so accordingly i would like to know how to find it out... I know that... (7 Replies)
Discussion started by: wrapster
7 Replies

8. Shell Programming and Scripting

Weblogic monitoring shell script

HI, I'm new in unix. I would like to know if you have a ready script for monitoring the weblogic and managed servers. I want to have a script that checks the weblogic once in a while if it's up and running. if not running, will send an email to me. any idea? please help me. i will... (4 Replies)
Discussion started by: tungaw2004
4 Replies

9. Shell Programming and Scripting

get home-directory in shell-scripts

Hi, does somebody know, how i can get the full path of my home-directory in a shell-script? But not with the $home-variable or ~ (i don't know for sure, but i think this does not work in every shell...). Thank You! Greetings, qsi (5 Replies)
Discussion started by: qsi
5 Replies

10. Solaris

Accessing the home directory in shell script

How can I access home directory in a shell script. I am writing a script which will delete the log files in each of the user's directory Krishan (1 Reply)
Discussion started by: krishan
1 Replies

Featured Tech Videos