You have to tell su to run the amanda users .profile .  "su - amanda" will do 
this for you..  If you omit the "-", su won't reconfigure the child shell's 
environment for amanda, it will simply continue with your existing environment.

Compare:

root@colias:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

root@colias:~# su jlellis -c 'echo $PATH'
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

  ( above, the jlellis shell isn't a login shell, so it didn't execute the 
/home/jlellis/.bash_profile setup, and thus did not setup my usual jlellis 
PATH.)


root@colias:~# su - jlellis -c 'echo $PATH'
/usr/local/sbin/PavlovDHCP:/usr/local/sbin/PavlovAbuse:/home/jlellis/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin

  ( Above, su told bash to run my .bash_profile, so it shows my personal PATH 
is set, not root's.)


root@colias:~# su - jlellis -c "echo $PATH"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

  (This one fails because I used " instead of '.  Thus, what the shell got was
    "echo /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games", a constant 
string.)


You have two issues confusing your debugging:  " vs ' in your -c parameter, and 
whether su runs
Your profile script, or not. 


-----Original Message-----
From: Gene Heskett [mailto:ghesk...@wdtv.com] 
Sent: Friday, February 6, 2015 15:09
To: Joi L. Ellis; amanda-users
Subject: Re: An odd problem...

On Friday, February 06, 2015 03:08:42 PM you wrote:
> Amcheck is a compiled binary, not a script.
> 
> With bash, if the path to a script's interpreter is invalid, it says 
> so with
> 
>       -bash: ./jj: /bash: bad interpreter: No such file or directory
> 
> But if it can't find the command you asked for, you get:
> 
>       -bash: ./jjj: No such file or directory
> 
> This is why I specify either 'sudo -i' or 'bash -l' when launching a 
> shell under a new name.  The parameters tell sudo and/or the shell to 
> launch a full 'login' shell, which ensures your PATH is set properly.
> If you omit that, it tends to simply use the existing PATH you had in 
> your original shell.
> 
Doing an su amanda -c  "echo $PATH"
shows the first 3 colon separated paths as all /usr/local/sbin where amcheck is 
installed.

This is the amanda $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

and because I've been playing, root now has 3 copies of that first path.

But it can't find it.  Owned by root:amanda on both the old drive and the new 
one.  And I'm walking around with half a cold cuppa, shaking my head.

> 
> -----Original Message-----
> From: owner-amanda-us...@amanda.org
> [mailto:owner-amanda-us...@amanda.org] On Behalf Of Jon LaBadie Sent:
> Friday, February 6, 2015 13:50
> To: amanda-users@amanda.org
> Subject: Re: An odd problem...
> 
> On Fri, Feb 06, 2015 at 12:11:23PM -0500, Gene Heskett wrote:
> > Greetings all;
> 
> ...
> 
> > then:
> > su amanda -c "amcheck Daily"
> > root@coyote:/home/amanda# su amanda -c "amcheck Daily"
> > su: Authentication failure
> > (Ignored)
> > sh: 1: amcheck: not found
> > 
> > But amcheck is sitting in /usr/local/sbin.  And its in the $PATH.
> 
> Is amcheck a script, possibly perl or shell.  If so, check the first 
> line which specifies the interpreter. Something like:
> 
>   #!/bin/perl
> 
> If it specifies the wrong location the shell reports "not found" just 
> like it would for the script not found.
> 
> Wish they would change that message.
> 
> Jon

Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS

Reply via email to