Bugün duyduğum diğer ilginç bir fikir, kök olarak çalıştırdığınızda ve komut dosyasını başka bir kullanıcı olarak çalıştırmak istediğinizde, komut dosyası üzerinde yinelenen bir çağrı yapmaktır. Aşağıdaki örneğe bakın:
ben "root" olarak senaryoyu "my_script" çalıştırıyorum ve komut kullanıcının Sen birden su
gömmek için bir here document kullanabilirsiniz
#!/bin/bash
#Script name is: my_script
user=`whoami`
if [ "$user" == "root" ]; then
# As suggested by glenn jackman. Since I don't have anything to run once
# switching the user, I can modify the next line to:
# exec sudo -u raamee my_script and reuse the same process
sudo -u raamee my_script
fi
if [ "$user" == "raamee" ]; then
#put here the commands you want to perform
do_command_1
do_command_2
do_command_3
fi
olası yinelenen [I su o kullanıcı olarak bash script kalanını yürütmek için nasıl kullanırım?] (Http://stackoverflow.com/questions/1988249/how-do- i-use-su-to-the-the-the-the-use-of-the-bash-betik-kullanıcı-kullanıcı olarak) –