.O problema é o meu id 'aaa' pode ler apenas o nome do arquivo e não o conteúdo dentro dele quando eu fizer login com o meu id "aaa". Então, para ler o conteúdo eu tenho que mudar para outro usuário "bbb" que está tendo permissão para ler o conteúdo desse arquivo usando o comando abaixo:
pbrun /bin/su - bbb
para automatizar o trabalho manual acima Eu escrevi um script para verificar todos os dias se um arquivo de trabalho publicado ou não. Como usar o comando acima dentro do meu script que é executado sob o meu 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" [email protected] <wa.txt
else
echo " $fname has not posted " >>wa.txt
mail -s "File ALERT" [email protected] <wa.txt
fi
rm wa.txt 2>ni.txt
eu tentei a opção abaixo, mas não funcionou.
#!/bin/ksh
pbrun /bin/su - bbb
resto do script ....
Tags sudo users shell-script filenames