Issue
I want to ask regarding su root -c '/some/foo/command' <<<'somepass'
. as we know we can't use string input redirection in shell (not bash) env.
For your information, my box is alpine on WSLv2, so security isn't an issue as it's a windows + WSLv2 dev box. The script can't be run with bash, as it's a /etc/profile.d/*.sh scripts, that run before user login and always use shell instead of bash, so I can't change the way it use bash, is there any possibility to pass the password to the input without using a flat file like in bash, or is there anyway to force /etc/profile.d/*.sh scripts run with bash instead of normal shell script interpreter?
any pointer to this appreciated. Thank you! NB: if you think this should be on serverfault, please let me know, as my opinion this should be on scripting side, so the most suitable site is stackoverflow. Thank you.
Solution
If you are just asking how to do a herestring when the shell you are using does not support herestrings, then:
su root -c '/some/foo/command' << EOF
somepass
EOF
I can't write this response without at least remarking that passing a password this way is not secure.
Answered By - William Pursell Answer Checked By - Mildred Charles (WPSolving Admin)