any linux guru ?

edited February 2012 in Chit chat
i have following problem:

(if you have experience with linux, ant and jenkins read bellow)

as part of automatic tests i have to run installer/uninstaller of (nonamed) sw.
the installer is bash script and due someones 'good' idea it must to run under root

BUT

we run all testing process from jenkins as an ant job and installation is done on jenkins slaves via ssh. jenkins currently logins as root but i dont want it to leave it this way.

so the correct way should be log as dedicated user (say jenkins) and do

sudo bash -c 'nameofthebashinstaller -andparamsforsilentinstall'

but im constantly getting
sudo: bash -c 'nameofthebashinstaller -andparamsforsilentinstall' :command not found

note thats in case this is <exec>uted from ant build.xml

strangely enough, typing exactly same command under same user (not root) directly will pass.

can anyone help (please avoid blind shots - i spend last 2 hours by googling and throwing away useless solution).

thanks in advance.
Post edited by Fikee on

Comments

  • edited January 2012
    You probably want to check the sudoers file to see if the current user is allowed to run bash as root (normally running shells is prohibited, since it allows circumvention of sudo's logging).

    Assuming that's ok, you may need to provide a full path to bash, depending on how your OS is configured.
  • edited January 2012
    AndyC wrote: »
    You probably want to check the sudoers file to see if the current user is allowed to run bash as root (normally running shells is prohibited, since it allows circumvention of sudo's logging).

    Assuming that's ok, you may need to provide a full path to bash, depending on how your OS is configured.

    good point, will try. thanks
  • edited February 2012
    ~$ sudo echo $PATH
    /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    ~$ sudo bash -c 'echo $PATH'
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
    
    In short: check environment / search path for user (and root?). And what's used when that build script runs.

    What is used to find executables, might not be what you think it is. Especially when running a script from a build framework that may change/set environment variables before executing parts of the process. Btw is that bash installer marked executable for the user that runs it?
  • edited February 2012
    Fikee wrote: »
    sudo bash -c 'nameofthebashinstaller -andparamsforsilentinstall'

    As others have mentioned, check the paths relevant for the bash script under sudo.

    However, I wonder why you do it that way? It would be more "safe" to do
    sudo /full/path/to/thebashinstaller -andparamsforsilentinstall
    
  • edited February 2012
    and this is why Linux will never be the top OS.

    Because the normal user would never get into the bash commands and such.
  • edited February 2012
    morcar wrote: »
    and this is why Linux will never be the top OS.

    Because the normal user would never get into the bash commands and such.

    This is a developer, and these tasks are for development - not "normal users". On Windows, a developer would have to do similar kind of things, edit build scripts, write command line tools etc. to control automated building and testing. Same is true for Mac OSX. The Spectranet build is all done on my Mac, but it's all command line. Automation of builds and testing is far easier to do by writing scripts than clicking buttons.

    For normal users doing desktop things on any vaguely recent Linux distro, you never need to open a terminal window. Things have moved on since 1999...

    In any case Linux *is* the top OS, on mobile phones. Android currently has the largest smartphone share. Android is Linux based. Microsoft is relegated to a mere "also ran" in the smart phone (really, pocket computer) world.
Sign In or Register to comment.