How to login as another user and then log out in bash script?
Posted
by Neuquino
on Stack Overflow
See other posts from Stack Overflow
or by Neuquino
Published on 2010-03-29T14:26:17Z
Indexed on
2010/03/29
14:33 UTC
Read the original article
Hit count: 237
Hi, I need to write a bash script to do something as another user and then return to the initial user...
Suppose I run the following as root:
#!/bin/bash
USER=zaraza
su - "${USER}"
#do some stuff as zaraza
________ #here I should logout zaraza
#continue doing things as root
In the console I should write "exit", but in bash is a keyword and it exits the script...
Thanks in advance,
© Stack Overflow or respective owner