Hi there
I am trying to create a script where I am checking the process is being run by the correct user, when I go to run the script it is not returning what I am expecting and I am not 100% sure why!!!
First off I have determined what the process user should be at the top of the script
enterprise_manager_user="casupport"
Then I have ran the process as I would normally in the command line
em_process_user=`ps -efl | grep 'Introscope_Enterprise_Manager.lax' | grep -v grep| awk '{print $3}'`
- An example below on the return from that:
[casupport@wycvlapph048 enterprisemanager]$ ps -efl | grep 'Introscope_Enterprise_Manager.lax' | grep -v grep| awk '{print $3}'
root
[casupport@wycvlapph048 enterprisemanager]$
I have then wrote my script saying if the em_process_user = enterprise_manager_user
then do this if not do this. I am expecting it to return as root but as determined at the top of the script I have said enterprise_manager_user should = user casupport so should alert however it doesn't
if [ "$em_process_user"="$enterprise_manager_user" ]
then
em_process_user_flag=0
else
em_process_user_flag=1
fi
echo $em_process_user_flag
echo $em_process_user
When I execute the script it comes with the following:
[casupport@wycvlapph048 enterprisemanager]$ ./test.sh
0
root
Surely it should come back as 1?
Thanks in advance for any help!