BladeSystem Forums Have Moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Showing results for 
Search instead for 
Do you mean 

error_in script

SOLVED
Go to Solution
Highlighted
Respected Contributor

error_in script

Hi

While executing this script

#################
echo "getting the events dump"
Date=$(date)
/opt/OV/bin/ovdumpevents > events
echo "now processing events"
more events |grep OVpatternDelete >list
Value=$(tail -1 list|awk '{print $8}')
EvDate=$(tail -1 list|awk '{print $3, $4, $5, $6, $7}'|cut -c -8,10-)
if [ ${Value} = "OVpatternDelete" && ${Date} = ${EvDate} ]
then
echo "processing mail"
else
echo "no action"
fi

i am getting the following error.

# sh ecschk.sh
getting the events dump
now processing events
ecschk.sh[10]: test: A ] character is missing.
no action


please help me to solve this.

Thanks & Regards
10 REPLIES
Honored Contributor

Re: error_in script

Hi,
replace
if [ ${Value} = "OVpatternDelete" && ${Date} = ${EvDate} ]
by
if [ ${Value} = "OVpatternDelete" -a ${Date} = ${EvDate} ]
HTH
Respected Contributor

Re: error_in script

Hi,

Thanks for the correction.

i replaced the as per your suggestion.

now am getting this error

sh ecschk.sh
getting the events dump
now processing events
ecschk.sh[10]: Jan: A test command parameter is not valid.
no action


Also please tell me the diff in && and -a.i dont have any experience in this.i just simply followed some sytax from google.

THANKS
Honored Contributor

Re: error_in script

one of the variables you set is probably evaluating to nothing - so you might want to try:

if [ "${Value}" = "OVpatternDelete" -a "${Date}" = "${EvDate}" ]

The && syntax for "and" doesn't work in a test statement in the HP-UX POSIX shell - the code you got from google was probably for another shell which supports both syntaxes...

HTH

Duncan

HTH

Duncan
Acclaimed Contributor

Re: error in script

[ Edited ]

>Duncan: The && syntax for "and" doesn't work in a test statement in the HP-UX POSIX shell

If you want to use &&, you need to use [[ ]]:
if [[ "${Value}" = "OVpatternDelete" && "${Date}" = "${EvDate}" ]]; then

Respected Contributor

Re: error_in script

Hi,

Thanks a lot for the information.

now i am facing another error while executing. This command will be executed by the application (as user bin ).i tried a lot with changing permission and all . please have a look into this

Tue Jan 05 12:57:38 Command "/usr/sbin/evdel.sh" returned standard error data:
/usr/sbin/evdel.sh[5]: /tmp/ActionNNM/events: Cannot create the specified file.
/tmp/ActionNNM/events: No such file or directory
list: No such file or directory
rm: events non-existent

Thanks
Acclaimed Contributor

Re: error in script

[ Edited ]

>This command will be executed by the application (as user bin).

Typically bin isn't a real user. How are you logged into bin?)

>"/usr/sbin/evdel.sh" returned standard error data:
/usr/sbin/evdel.sh[5]: /tmp/ActionNNM/events: Cannot create the specified file.

Does the directory /tmp/ActionNNM exist? If not, you can always use "mkdir -p /tmp/ActionNNM" to make sure.
Does that directory have the right permission?
ll -d /tmp/ActionNNM

Respected Contributor

Re: error_in script

Hi

Thanks for the quick response.

I didn't logged in as user bin.But when my application executes command as bin.

ll /tmp/ActionNNM/
total 112
-rw-r--r-- 1 bin bin 19140 Jan 5 13:19 action.log
-rw-r--r-- 1 bin bin 2580 Jan 5 13:19 action1.log
drwxr-xr-x 2 root sys 8192 Jan 5 12:44 back
-rwxr-xr-x 1 bin bin 655 Jan 5 12:51 evdel.sh
-rw-r--r-- 1 bin bin 382 Jan 5 12:54 list

Please check the permissions
Respected Contributor

Re: error_in script

# ll -d /tmp/ActionNNM
drwxr-xr-x 3 root sys 8192 Jan 5 12:54 /tmp/ActionNNM
Acclaimed Contributor

Re: error in script

[ Edited ]

>But when my application executes command as bin.

That's pretty strange. It would make more sense to create a special user and not use one of the system UIDs.

>drwxr-xr-x 3 root sys 8192 Jan 5 12:54 /tmp/ActionNNM

This does not allow user bin to create the file events. root must create the file and chown it to bin:bin, then bin can write to it.
Or maybe you should have bin own the directory?

Acclaimed Contributor

Re: error_in script

Hi:

> But when my application executes command as bin.

Do you mean that you want files created by your application to be owned by 'bin'?

If so, you can have the _group_ ownership set to 'bin' simply by setting the 'setgid' bit on the parent directory:

# chgrp bin /tmp/ActionNNM
# chmod g+s /tmp/ActionNNM

Now files createed in the directory will automatically have a group ownership of 'bin'. The file's owner will remain that of the effective uid of the process creating them, but this is a way to grant group visability.

Regards!

...JRF...