tags:

views:

634

answers:

1

Hi, I am new to bash. I need to write the script which executes the following commands consecutively su - bbt; id

and to see the result. I have tried to put this line into the tmp.sh and then run it. I just see the results of the first command su - bbt. I don't see the results for the id command.

A: 

Try this:

su -c 'bbt; id'

Barun
Did you mean: sh -c 'su - bbt; id'?
William Pursell
su -c will relay to sh -c (in the new session)
TheBonsai
I got your question wrongly. You want to change the user as 'bbt' and then run the command 'id', right? Then you should try as:su - bbt -c 'id'
Barun
The command I wrote in my initial comment would work differently. It would execute the commands 'bbt' and 'id' sequentially with root privileges.
Barun