#!/bin/bash
su - john
(in john environment)
cd scripts
go.sh (with john variables)
exit
in this case, the user became murex but next command after "su - john"
goes in root user
how can i do? i tried with:
#!/bin/bash
su - john <<- END
(in john environment)
cd scripts
go.sh (with john variables)
exit
END
but it doesn't work
thanks
You need to review the 'su' manpage... in particular, the '-c' argument,
which acts much like -c when supplied to a shell.
su - john -c '/usr/bin/env'
However, be aware that it might not pick up environment settings from
the user's .profile and the like. (It probably will, but I've seen
cases where it didn't.) Be careful how much you assume.
--
Brandon Hume - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
You can do this:
su - john -c "/scripts/go.sh"
man su:
To execute command with the temporary environment and per-
missions of user bin, type:
example% su - bin -c "command args"
or
su - user -c "cd scripts; ./go.sh"