Search code examples
linuxshellsqlplussudosu

shell scripting that uses sudo su - team and perform rest command under this sudo access only


#!/bin/bash
sudo su - team  //// this will change user to team
<somecommnand>

here i have some command like sqlplus that run under this privilege only .

but ,this script first asked for password then i give password but it not run rest of command like .

How to write script that use sudo su and run all command in script below it.


Solution

  • You could try having all of the commands on the same line and seperate them with ';'.

    eg. 'sudo su; somecommand; another command'

    Could also run that script as the intended user.