2

we are running script the the first command in it is

su (switch user)

and after that other command:

#!/bin/bash
su sys_osrqa
whoami
pwd

but when the script run, it asks for password, and after we enter the password (manually) the script stops and doesn't proceed to the following commands:

Password:
icsl0760>

ant that's it. The commands "whoami" and "pwd"are not executed.

1 Answers1

1

su starts an interactive shell. If you want it to run explicit commands, use the -c option. In your case, I think that your script would become:

su -c 'whoami; pwd' sys_osrqa
Nick Sillito
  • 1,596