[ale] bash script with su

Jim Kinney jim.kinney at gmail.com
Mon Jun 8 11:14:54 EDT 2009


yes. The postgres commands are part of the postgres install and are
found in $PGHOME/bin so the $PATH for posgres _should_ have the data.

My understanding of su is that using the "-" or "-l" flag makes it a
login shell and thus uses all of that users environment data. So
having the PATH set in ~postgres/.bashrc should make it available to a
su -l postgres -c "<stuff>" process.

The ordering is not supposed to matter except that the command MUST be
after -c. The -/-l can have the user name after or at the end of the
line. I've even run su -c <stuff> -l <user> with the same results.

Most strange.

On Mon, Jun 8, 2009 at 10:54 AM, Jerald Sheets<questy at gmail.com> wrote:
> Is it possible the arg/command itself is in the wrong place?
>
> su [OPTION] ... [-] [USER [ARG]...]
>
> Would flipping the order have any effect?
>
> su -l postgres -c "initdb && pg_ctl start && createlang plpgsql template1 &&
> createdb batadm && createuser -s batadm " >>$log 2>&1
>
>
>
> (keep in mind I'm learning here a bit too.  I've had weirdness with commands
> preferring a particular order when the docs were not clear the order was
> important (or required)
>
> Also, the question I have about the create commands (I don't use
> postgres...  sorry for the newbieness).  Are createdb and createuser
> postgres commands on the fs somewhere?
>
> I also notice that the -l option's normal operation (according to the info
> pages) will "Unset all environment variables except 'TERM', 'HOME',
> 'SHELL', 'USER' and 'LOGNAME', and set 'PATH' to a compiled-in default
> value.  Change to the USER's home directory and prepend '-' to the shell's
> name, intended to make it read its login startup file(s)"
>
> Are these perhaps thwarting you as well?
>
>
> Hope it has bearing, and thanks in advance for the answers...
>
>
> --j
>
> On Mon, Jun 8, 2009 at 10:18 AM, Jim Kinney <jim.kinney at gmail.com> wrote:
>>
>>
>> su -l -c "initdb && pg_ctl start && createlang plpgsql template1 &&
>> createdb batadm && createuser -s batadm " postgres >>$log 2>&1
>>
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
>



-- 
-- 
James P. Kinney III
Actively in pursuit of Life, Liberty and Happiness



More information about the Ale mailing list