开发者

Linux sudo, [ant:sshexec] Remote command failed with exit status 127

开发者 https://www.devze.com 2023-04-06 06:42 出处:网络
A little background: I have a gradle script that I use in order to install and setup several softwares on many different machines - I run this locally with the purpose to accelerate the deployment pro

A little background: I have a gradle script that I use in order to install and setup several softwares on many different machines - I run this locally with the purpose to accelerate the deployment process. The gradle script gets the layer and the server name in as parameters and will install the softwa开发者_如何学运维re by executing a remote ssh linux command (rhel 6).

C:\work\source\tools\environment-tools>gradle -Player=service -Pserver=demo1 installSamba
Using libraries from: C:\work\source/lib
:installSamba
Trying to override old definition of datatype scp
Trying to override old definition of datatype sshexec
 --- Executing: yes | yum install samba
 --- failOnError = false, using sudo
 >>>>>
Command: echo 'sudo_pass' | sudo -Ss 'yes | yum install samba'
[sudo] password for root:
/bin/bash: yes | yum install samba: command not found

[ant:sshexec] Remote command failed with exit status 127

the command i am trying to execute: simply uses yum to install samba but also triggers a yes in order to automaticaly perform a default samba installation.

The question: When i execute the script, the following command is remotely executed to install samba: echo 'sudo_pass' | sudo -Ss 'yes | yum install samba'

why would this fail when the following executes perfectly (but with human interaction, i.e. press y and then return): echo 'sudo_pass' | sudo -Ss yum install samba

i imagine i would need to setup the following small gradle installation script correctly: any idea of what i am doing wrong?

task installSamba << {
  forAllServers { props ->
    ssh('yes | yum install samba', props)
  }
}


I later found out that a downgrade of sudo on the remote machine was necessary in order to execute a gradle script like the one above. the downgrade i did was from version: 1.7.4p5 to sudo version 1.7.2p2. This is a working alternative, but not the best solution. I would rather have the latest sudo update running on the host. The real question then is: how would one go about and fix the above simple script in order for it to execute

0

精彩评论

暂无评论...
验证码 换一张
取 消