pg

#!/bin/bash

function me()
{
echo "im $(whoami) "
}

Test that it works.

me
sudo -u test whoami
sudo -u test me
FUNC=$(declare -f me)
sudo -u test bash -c "$FUNC; me"
me

#sudo -u test bash -c "$(declare -f me); me"


[root@server ~]# ./test.sh
im root
test
sudo: me: command not found
im test
im root

发表评论

您的电子邮箱地址不会被公开。

Captcha Code