Hi All,
I am new to shell scripts and would appreciate help plz
I have a script:
> cat newmyEnvSendAlarm
/users/netrac/.cshrc
/users/netrac/.profile
/users/netrac/.login
>
where .profile is
#!/bin/sh
echo profile start
PATH=/usr/local/bin:/usr/b
in:/etc:.:
/usr/sbin:
/sbin:/usr
/ccs/bin:/
netrac/pro
grams:/tti
/scripts:/
sybase/bin
:/sybase:/
usr/local/
bin
MANPATH=
LIBPATH=/sybase/lib
SHLIB_PATH=/sybase/lib
LD_LIBRARY_PATH=/sybase/li
b
export PATH MANPATH LIBPATH SHLIB_PATH LD_LIBRARY_PATH
etc.
.login
#!/bin/csh
stty erase "^H"
stty intr "^C"
stty kill "^U"
#stty echoke
setenv PATH /usr/local/bin:/usr/bin:/e
tc:.:/usr/
sbin:/sbin
:/usr/ccs/
bin:/netra
c/programs
:/tti/scri
pts:/sybas
e/bin:/syb
ase
setenv MANPATH /usr/dt/man:/usr/man:/usr/
openwin/sh
are/man:/u
sr/local/m
an
setenv LIBPATH /sybase/lib:/netrac/netrac
II/version
/SunOS/lib
setenv SHLIB_PATH /sybase/lib
setenv LD_LIBRARY_PATH /sybase/lib:/netrac/netrac
II/version
/SunOS/lib
# Preferences
setenv PAGER /usr/local/bin/less
setenv EDITOR vi
setenv VISUAL vi
setenv USER $LOGNAME
setenv TERM vt100
etc.
and .cshrc as :
!/bin/csh
if ($?prompt) then
set history=100
set filec
set biff
set notify
set printexitvalue
umask 02
endif
set prompt="%M[%h] %~> "
alias a alias
# General Aliases
a c clear
a j jobs -l
a h history
a ls ls -FC
a ll ls -ls
a d ls -l
a lt 'ls -lt | head'
newmyEnvSendAlarm runs in tshell as below:
> source newmyEnvSendAlarm
profile start
profile end
....
>
Now I thought newmyEnvSendAlarm will set up environment for me for .profile, .login etc etc...
I call it from java program as below:
command = "env;source /export/home/netrac/progra
ms/newmyEn
vSendAlarm
;env;/expo
rt/home/ne
trac/progr
ams/send_a
larm2 f + " + "\""+argus_id+"\" ";
command += "\""+reported_time+"\" "+ "15002 " + "\"\" " + "\""+alarm_description+"\"
";
command += "\""+location+"\" " + "\""+managed_entity+"\" ";
out = new FileOutputStream ( "updatesfrompushalarms.txt
");
rc = m_runTelnetCommands.runRem
oteCommand
(out,
m_dbCons.getIP(m_dbCons.IN
DEX_NETRAC
),
m_dbCons.getUsr(m_dbCons.I
NDEX_NETRA
C),
m_dbCons.getPswd(m_dbCons.
INDEX_NETR
AC),
command);
I need to set up environment to execute send_alarm2 program..
and since I call it from java from another server, so .profile, .login doesnt execute .. and so I wrote a script newmyEnvSendAlarm which can actually set up the environment and then call send_alarm2 program..
But its not happening... if u can guide me why.. wud be helpful..
If i instead replace the contents of newmyEnvSendAlarm by actual environment variables as below:
setenv HOME /users/netrac
set PATH=(/usr/local/bin:/usr/
bin:/etc:.
:/usr/sbin
:/sbin:/us
r/ccs/bin:
/netrac/pr
ograms:/tt
i/scripts:
/sybase/bi
n:/sybase:
/netrac/ne
tr
acII/version/SunOS/bin)
setenv LOGNAME netrac
setenv HZ 100
setenv TERM vt100
setenv TZ US/Eastern
setenv MAIL /var/mail/netrac
setenv LC_COLLATE en_US
setenv LC_CTYPE en_US
setenv LC_MESSAGES C
.........
and source is, it works fine..
but I instead want to use exising .profile and .login etc here..
for information, server has tsch as default which cannot be changed..
regards