1752798 Members
5562 Online
108789 Solutions
New Discussion юеВ

Re: Need help

 
CSHELL
New Member

Need help

Hi,
I have written a shell script and getting error.Any help on how to fix it.

update a439487.ora_dev_inventory set HA='${sa_svr}' where lower(HOST_NM)='${pa_svr}' and INV_DT=sysdate;..i getting error in this line.

I have set the environment variable (sa_svr,pa_svr).


error message.


Bad : mod in $.

Any help/
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Need help

The first thing you should do is throw the scummy csh in the garbage and use a real shell, sh or ksh.

You example seems to mix comments and shell commands, please put them one per line so we can see them. Or you may have to attach your script.
CSHELL
New Member

Re: Need help

i have pasted script below.

#!/bin/csh
sqlplus / << EOF > vinoth.log
set heading off;
set serveroutput on;
DECLARE
instance_nme varchar2(30);
rac_status varchar2(10);
host_nme varchar2(20);
begin
select instance_name,host_name,parallel into instance_nme,host_nme,rac_status from v\$instance;
dbms_output.put_line(instance_nme||':'||host_nme||':'||rac_status);
end;
/
EOF
##Ogrep -vw "YES" vinoth.log > vinoth1.log
grep "YES" vinoth.log > vinoth1.log
cat vinoth1.log|awk -F: '{print $2}' > vinoth_nrac.log
foreach host ( `cat /datdevdal2/fdat/dev/vinoth/vinoth_nrac.log` )
#do
rsh $host -l datprd ps -ef|grep had|grep -v grep > /tmp/vinoth.txt
if ( ! -z /tmp/vinoth.txt) then
rsh $host -l datprd cat /etc/llthosts|grep -w 1|awk '{print $1":"$2}'> ha2.txt
##rsh $host -l datprd cat /etc/llthosts > temp.txt
set sa_svr=`cat ha2.txt|awk -F: '{print $2}'`
##set pa_svr=`cat ha2.txt|awk -F: '{print $1}'`
rsh $host -l datprd cat /etc/llthosts|grep -w 0|awk '{print $1":"$2}'> ha3.txt
set pa_svr=`cat ha3.txt|awk -F: '{print $2}'`
echo $sa_svr
echo $pa_svr

-----Till this no error looks fine.
#db_nm=`grep $1 vinoth.log|awk '{print $1}'`
sqlplus / << EOF > vintoh_update.log
update a439487.ora_dev_inventory set HA='${sa_svr}' where lower(HOST_NM)='${pa_svr}' and INV_DT=sysdate;

#rsh $1 -l datprd cat /etc/llthosts|grep -w 1|awk '{print $2}' > ha2.txt
#echo "$1:`cat ha2.txt`"
commit;
/
endif
EOF
#done
Dennis Handly
Acclaimed Contributor

Re: Need help

>Bad : mod in $.

Reading the scummy csh man page carefully shows this is the bad line:
#echo "$1:`cat ha2.txt`"

You need to change it to:
#echo "${1}:`cat ha2.txt`"

If you used a real shell you could just do:
echo "$1:$(< ha2.txt)"
James R. Ferguson
Acclaimed Contributor

Re: Need help

Hi:

I'm with Dennis. Avoid the C shell! You should read this classic post by Tom Christiansen:

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

I would urge you to use the standard HP-UX shell ('/usr/bin/sh') which is a POSIX superset of the Korn shell. For 'root' this shell exists as '/sbin/sh' and is a statically linked binary necessary during boot up when '/usr' isn't mounted and hence the dynamic libaries are not available.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Need help

If your question is answered, please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33