I am writing a build script. This script has to copy a file in the end. This file will be placed in another users home directory and it is also necessary that the file belongs to this second user. My first attempt was to use su like this:
su fbgs -c "cp fbgs.jar /home/fbgs/server/plugins/"
This works in the command line but when I put this in the script I need the password to be entered automatically. So I tried the following command:
echo Password | su -S fbgs -c "cp fbgs.jar /home/fbgs/server/plugins/"
But then I get this output:
su: must be run from a terminal
How do I get this to work?