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