| Author |
how to logout from a shell script
|
|
| gotothati@gmail.com 2006-12-28, 1:34 am |
| hi all
I am writing shell script which wil be executed by a process with root
permissions.
I wil login to other user account using su command.
like this:
su username
...do the needful..
Now I want to come to previous state again ( i.e as root )
I am trying to use exit in the shell script but its making the sub
shell to come out and not logging out the user.
How can do exit from a shell script ??
Thnks to all.
Ravi.
| |
| Bill Marcum 2006-12-28, 7:32 am |
| On 27 Dec 2006 22:15:23 -0800, gotothati@gmail.com
<gotothati@gmail.com> wrote:
>
>
> hi all
>
> I am writing shell script which wil be executed by a process with root
> permissions.
>
> I wil login to other user account using su command.
>
> like this:
>
> su username
> ...do the needful..
>
>
> Now I want to come to previous state again ( i.e as root )
> I am trying to use exit in the shell script but its making the sub
> shell to come out and not logging out the user.
>
> How can do exit from a shell script ??
>
If you exit from the script containing the su command, how can the user
still be logged in? Please post your script.
--
BOFH excuse #189:
SCSI's too wide.
| |
| Hubble 2006-12-28, 7:32 am |
|
gotothati@gmail.com schrieb:
> I am writing shell script which wil be executed by a process with root
> permissions.
>
> I wil login to other user account using su command.
>
> like this:
>
> su username
> ...do the needful..
>
>
> Now I want to come to previous state again ( i.e as root )
> I am trying to use exit in the shell script but its making the sub
> shell to come out and not logging out the user.
>
> How can do exit from a shell script ??
If I understand you right, you want to logout from a script. This is
not possible. However, depending on your login shell, the following may
help:
exec su username
....do the needful..
(exec executes a command as replacement of the current shell)
Hubble.
| |
| martin.witte@gmail.com 2007-01-06, 8:00 pm |
|
On Dec 28, 7:15 am, gototh...@gmail.com wrote:
> hi all
>
> I am writing shell script which wil be executed by a process with root
> permissions.
>
> I wil login to other user account using su command.
>
> like this:
>
> su username
> ...do the needful..
>
> Now I want to come to previous state again ( i.e as root )
> I am trying to use exit in the shell script but its making the sub
> shell to come out and not logging out the user.
>
> How can do exit from a shell script ??
>
> Thnks to all.
>
> Ravi.
You can run the script as 'su - root -c <here the name of the script>'
|
|
|
|