-rwxr--r-- 1 root root ...... ps
This says that the user who owns it has read, write, and execute permission, and all others just read. So nobody but root can execute
The script you wrote is executable by all, but inherits the permissions from the one who invokes it, so he also gets the "permission denied" when trying to execute the
ps, as he is still a normal user.
My guess is that you want to prevent regular users from executing
ps with certain options (not that it makes sense to me), but then you have to add the
setuid bit or
setgid bit to your script (see man page of
chmod). When you do this it gets the permissions not from the invoker of the script, but from the one who owns the script.
BUT BEWARE: Setting the
suid bit on scripts is inherently insecure. You can do very much with environment variables, that e.g. tell the shell to execute commands - and then they are executed as root (here a custom c-program with the sticky bit is the better solution).
EDIT: Another solution would be to use
sudo. Here you can also configure which parameters are allowed to a
EDIT2: Why I think it is not a good idea to prohibit user just from executing
ps? As far as I know, all the information
ps outputs can be also be acquired via the
/proc system - so if you do nothing else it is just security (or whatever you want to achieve) by obfuscation.