
다음 명령을 실행하려고 합니다.
if [! -f .owner ]; then
creator=$(whoami)
sudo -u appuser ksh
echo "$creator" >> .owner
mkdir test1 test2 test3
exit
fi
그러나 파일/폴더는 스크립트를 실행하는 사람이 생성합니다. appuser가 이를 생성할 수 있는 방법이 있습니까?
편집하다: sudo -l
반품(appuser) NOPASSWD: ALL
답변1
노력하다:
#!/bin/bash
id
touch script-run-user.file
sudo -u appuser 'ksh' <<EOF
# add list of cmds to execute
id
touch appuser.file
EOF
편집하다: 방금 업데이트되었습니다. 확인해 보세요.여기에 파일. EOF = "파일 끝", 임의의 이름.