2021年4月11日星期日

Runuser Not Return Expected Results

There are two accounts in my linux computer, appuser and root. For testing purpose I wroto below code into /home/appuser/.profile

export key=value  

then as root I execute below commands separately:

1. runuser -l appuser -c "echo key=$key"       expected: key=value     result:    key=       2. runuser -l appuser -c "/home/appuser/test.sh"        test.py includes only two lines:        #!/bin/bash      echo "key=$key"        expected: key=value      result:    key=value  

Why can't the first command return the correct result?? Is that because .profile is not sourced during execution? why?

https://stackoverflow.com/questions/67051022/runuser-not-return-expected-results April 12, 2021 at 07:18AM

没有评论:

发表评论