.The issue is my id 'aaa' can read only the file name and not the contents inside it when I log in with my id "aaa". So to read the contents I have to switch to another user "bbb" which is having permission to read the contents in that file by using the below command:
pbrun /bin/su - bbb
to automate the above manual work I have written a script to check everyday whether a job file posted or not. How to use the above command inside my script which is executed under my id 'aaa'?
#!/bin/ksh fname = /home/job/file1.log #this is the path where file1.log will be posted everyday var =$(grep 'job finished successfully ' $fname ) # my id 'aaa' is not having privilege to read file contents only # id 'bbb' is having the privilege so when i execute the script with # my id the above line wont work . if [ -e "$fname"] && [! -z "var"] echo " $fname has posted successfully " >>wa.txt mail -s "File ALERT" firstname.lastname@example.org <wa.txt else echo " $fname has not posted " >>wa.txt mail -s "File ALERT" email@example.com <wa.txt fi rm wa.txt 2>ni.txt
i tried below option but it did not work .
#!/bin/ksh pbrun /bin/su - bbb
rest of the script ....