Weblogic WLST classpath - weblogic-10.x

When I run the WLST script .sh script to set the env as follows why can't I see the updated path when I do echo?
[linbox2 bin]$ ./setWLSEnv.sh
CLASSPATH=/directory/ols_wls/patch_wlss1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/directory/ols_wls/patch_wls1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/directory/ols_wls/patch_oepe1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/directory/ols_wls/patch_ocm1031/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/directory/ols_wls/jrockit_160_14_R27.6.5-32/lib/tools.jar:/directory/ols_wls/utils/config/10.3/config-launch.jar:/directory/ols_wls/wlserver_10.3/server/lib/weblogic_sp.jar:/directory/ols_wls/wlserver_10.3/server/lib/weblogic.jar:/directory/ols_wls/modules/features/weblogic.server.modules_10.3.2.0.jar:/directory/ols_wls/wlserver_10.3/server/lib/webservices.jar:/directory/ols_wls/modules/org.apache.ant_1.7.0/lib/ant-all.jar:/directory/ols_wls/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar:
PATH=/directory/ols_wls/wlserver_10.3/server/bin:/directory/ols_wls/modules/org.apache.ant_1.7.0/bin:/directory/ols_wls/jrockit_160_14_R27.6.5-32/jre/bin:/directory/ols_wls/jrockit_160_14_R27.6.5-32/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/java/j2sdk1.4.2_11/bin/bin:/home/oracle/bin:/directory/wls_olwcs/jdk160_14_R27.6.5-32/bin:/directory/ccanywhere81/bin:/directory/oracle/oracle/product/10.2.0/client_1/bin
Your environment has been set.
[linbox2 bin]$ export CLASSPATH
[linbox2 bin]$ export PATH
[linbox2 bin]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/java/j2sdk1.4.2_11/bin/bin:/home/oracle/bin:/directory/wls_olwcs/jdk160_14_R27.6.5-32/bin:/directory/ccanywhere81/bin:/directory/oracle/oracle/product/10.2.0/client_1/bin

You need to run the script in your current shell.
$. ./setWLSEnv.sh
Note the the two periods and the space between them. The way you are running the script now, the path is updated in the shell created for the script which closes once the script finishes running.
Adding the period before the script will run the script in your current shell.

The export commands you have used after setWLSEnv.sh is going to invalidate the settings that made by the script. Better you run the script setWLSEnv.sh and then use echo $PATH. Hope this will help.

Related

Different java version in .sh file and terminal MAC

I'm trying to set JAVA_HOME in macOS 10.14. Currently there are 2 jdk versions (jdk-11.0.8.jdk, jdk-14.0.2.jdk) installed in /Library/Java/JavaVirtualMachines and I've exported env variable in .bash_profile
export JAVA_HOME=`/usr/libexec/java_home -v 11`
In terminal all is ok. java -version prints 11.0.8, echo $JAVA_HOME shows 11's directory.
But in ~/test.sh file java -version prints 14.0.2, $JAVA_HOME is empty. I tried to set env var in etc/profile but no success. Does anyone know what could possibly cause this?
Welcome to the wonderful world of POSIX semi-compatible shells :-)
From the bash man page:
When bash is invoked as an interactive login shell, or as a non-interactive shell
with the --login option, it first reads and executes commands from the file
/etc/profile, if that file exists. After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and exe-
cutes commands from the first one that exists and is readable. The --noprofile
option may be used when the shell is started to inhibit this behavior.
Note that simply running a script does not execute the ~/.bash_profile script as the script is neither interactive nor a "login" shell. One solution is to set the BASH_ENV var to an appropriate initialization script.

Unable to export environment variables in cygwin within a shell script

I created a setenvj1.6 shell script in my /usr/local/bin directory, in cygwin (Windows 7).
setenvj1.6:
export PATH=/cygdrive/c/bea/bea10/bea10g3/jdk160_05/bin:$PATH
export JAVA_HOME=/cygdrive/c/bea/bea10/bea10g3/jdk160_05
echo Set for Java 1.6
when I run setenvj1.6, like this:
myuser#mycomp /usr/local/bin
$ setenvj1.6
Set for Java 1.6
I see that the script has run, but when I check if anything is set correctly, I see that my variables are not set:
myuser#mycomp /usr/local/bin
$ echo $JAVA_HOME
Similarly, if I echo $PATH, I get my usual PATH variable but without the directory I tried to add with export.
How do I get this to work?
I need a bash script like the one I specified that I can run after I've run cygwin so that I can change my paths to whatever I want. Thanks.

how to execute this shell script

I have a shell script written in eclipse
#!/bin/sh
#
# 07/28/2006. .sh file for the Hpims Cron job.
# Runs daily.
. /db2/db2inst1/sqllib/db2profile
APPHOME=/devl/prod/vehmgr/cronjob/HpimsCron
JAVA_HOME=/usr/java14
JAVA_EXEC=$JAVA_HOME/bin/java
JAVAC=$JAVA_HOME/bin/javac
#export APPHOME JAVA_HOME JAVA_EXEC JAVAC
export JAVA_HOME JAVA_EXEC JAVAC
cd $APPHOME
CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/jre/lib/i18n.jar:/appl/jConnect/classes
/jconn2.jar:/appl/net/jserv-1.1.2/libexec/jndi.jar
CLASSPATH=$CLASSPATH:/appl/net/jserv-1.1.2/libexec/mail.jar:/appl/net/jserv-1.1.2/libexec/mailapi.jar:/appl/net/jserv-1.1.2/libexec/activation.jar
CLASSPATH=$CLASSPATH:/appl/net/jserv-1.1.2/libexec/smtp.jar:/appl/net/jserv-1.1.2/libexec/soap.jar:/appl/net/jserv-1.1.2/libexec/ldap.jar
CLASSPATH=$CLASSPATH:/home/db2inst1/sqllib/function:/home/db2inst1/sqllib/java/db2java.zip
CLASSPATH=$CLASSPATH:.
CLASSPATH=$CLASSPATH:/devl/prod/vehmgr/cronjob/HpimsCron
export CLASSPATH
#cd $APPHOME
#$JAVAC HpimsCron.java
$JAVA_EXEC HpimsCron
Question is - how to execute this shell script on Windows XP. I have made changes to the HpimsCron.java file and now I need to run this shell script manually to see the changes reflected.
In general I'd do the following:
CLASSPATH=something
CLASSPATH=$CLASSPATH:something/else
export CLASSPATH
Becomes
set CLASSPATH=something
set CLASSPATH=%CLASSPATH%;something\else
(note, the ; instead of : and \ instead of /)
EDIT:
The call to dbprofile suggests another script that may not be portable and whether the app (HpimsCron) would work on Windows is also highly dubious.
Cygwin will allow you to run shell commands on Windows. This post How do you run a crontab in Cygwin on Windows? also explains how to get cron working on Windows under Cygwin.
This won't run under Windows, it's Unix shell specific
You might give Cygwin a try. It offers a Unix-like environment on a Windows system.

Export environment variables using script

I need to set some environment variables in Ubuntu. I do the following and it works:
export PATH="/home/vagrant/ns-allinone-2.35/bin:/home/vagrant/ns-allinone-2.35/tcl8.5.10/unix:/home/vagrant/ns-allinone-2.35/tk8.5.10/unix:$PATH"
export LD_LIBRARY_PATH="/home/vagrant/ns-allinone-2.35/otcl-1.14:/home/vagrant/ns-allinone-2.35/lib"
export TCL_LIBRARY="/home/vagrant/ns-allinone-2.35/tcl8.5.10/library"
But I move the same thing in a script envexport.sh and execute it, the environment variables are not getting set.
Where am I going wrong? How to accomplish this?
Thanks.
If you just run the script, the environment variables get destroyed when the script finishes.
Use . envexport.sh. That way the commands get executed in the current shell (environment).
When you run a command in the shell, the shell creates a subprocess (child process). All the environment variables which were defined or changed down in the subprocess will be lost to the parent process.
However if you source a script, you force the script to run in the current process. That means environment variables in the script you ran will not be lost.
One thing that may help is if you will want those variables set for all of your sessions you can place the same commands in your .bashrc file by running the following command and pasting the lines in the file.
vim ~/.bashrc
and the run
source ~/.bashrc
in any terminals you currently are running. If you start any new terminals they will automatically have your directories added to your path.

Shell script problem to set my env

We have few executable which need some environment setting.
We manually running those scripts before running the executable
Like
$ . setenv.ksh
We have to encompass call these in one script to avoid the manual work.
We written a sh script like
#!/bin/sh
. setenv.ksh
./abc &
Still the environments are not setting in that session. I think the “. setenv.ksh” runs with fork and it’s not setting the environment.
Please me to solve this problem. Which command we use to run the setenv.ksh so, this will work fine.
Thanks
I notice the environment script is called setenv.ksh but you try to run it from /bin/sh. Maybe your system has a shell other than ksh as /bin/sh and it misparses something it setenv.ksh. Try changing the shebang line to #!/bin/ksh (or whatever the path to ksh is on your system).
In setenv.ksh, you need to export all environment variables you set so that any sub-shell will inherit the values:
export MYENV=myValue

Resources