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.
From stackoverflow
-
Try this:
su -c 'bbt; id'
William Pursell : Did you mean: sh -c 'su - bbt; id'?TheBonsai : su -c will relay to sh -c (in the new session)Barun : 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.
0 comments:
Post a Comment