New answers tagged


We can use pipe for applying password and I have used it and it work perfectly well. COMMAND="${DIRECTORY}/" su -c postgres $COMMAND | passwd "enter your password here"


Several possibilities: sudo If you can configure it in a way that is both secure and flexible enough for your calls then you can use sudo to allow the script user to run the commands as user postgres without being asked for a password. sudo with wrapper script You can write a wrapper script which is writable by postgres or root only and checks that the ...


As @roaima pointed out, you likely want to run the script in a separate process. Sourcing it in your code without full understanding of it's internal workings can be rather dangerous: FILE_TO_REMOVE="/tmp/foobar" source some-cool-script rm -Rf "$FILE_TO_REMOVE" is rather obviously not the right way to go about things , because the cool script may so ...


The source their-script command tells your shell to execute their-script directly in the context of your script. This means it has access to all your variables, and can even change them. If you remove the word source and just run their-script as a command it will be unable to affect any of your code, and its $1 will be the first argument you give it, so in ...

Top 50 recent answers are included