Re: error_in script (214 Views)
Reply
Respected Contributor
Soul_1
Posts: 422
Registered: ‎09-08-2008
Message 1 of 11 (214 Views)
Accepted Solution

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
Please use plain text.
Honored Contributor
smatador
Posts: 628
Registered: ‎07-03-2002
Message 2 of 11 (214 Views)

Re: error_in script

Hi,
replace
if [ ${Value} = "OVpatternDelete" && ${Date} = ${EvDate} ]
by
if [ ${Value} = "OVpatternDelete" -a ${Date} = ${EvDate} ]
HTH
Please use plain text.
Respected Contributor
Soul_1
Posts: 422
Registered: ‎09-08-2008
Message 3 of 11 (214 Views)

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
Please use plain text.
Honored Contributor
Duncan Edmonstone
Posts: 5,678
Registered: ‎08-05-2000
Message 4 of 11 (214 Views)

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
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,958
Registered: ‎03-06-2006
Message 5 of 11 (214 Views)

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

Please use plain text.
Respected Contributor
Soul_1
Posts: 422
Registered: ‎09-08-2008
Message 6 of 11 (214 Views)

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
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,958
Registered: ‎03-06-2006
Message 7 of 11 (214 Views)

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

Please use plain text.
Respected Contributor
Soul_1
Posts: 422
Registered: ‎09-08-2008
Message 8 of 11 (214 Views)

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
Please use plain text.
Respected Contributor
Soul_1
Posts: 422
Registered: ‎09-08-2008
Message 9 of 11 (214 Views)

Re: error_in script

# ll -d /tmp/ActionNNM
drwxr-xr-x 3 root sys 8192 Jan 5 12:54 /tmp/ActionNNM
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,958
Registered: ‎03-06-2006
Message 10 of 11 (214 Views)

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?

Please use plain text.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 11 of 11 (214 Views)

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...
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation