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?