我有一个包含以下内容的shell脚本。
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get -y install python3-pip
pip3 install -r requirements.txt
echo "PIP RAN SUCCESSFULLY"
get_param_value()
{
param_name=$1
param_value=`aws --region=eu-west-2 ssm get-parameter --name $param_name --profile XYZ --with-decryption | grep Value | awk -F':' '{print $2}' | sed --expression='s/[ ",]//g'`
echo $param_value
}
export ACCESS_KEY=$(get_param_value ACCESS_KEY)
因此,每当我使用Fabric运行此脚本时,都会出现以下错误。
第6行:aws:找不到命令
以下是我的python代码以使用Fabric运行此文件
with cd(FABRIC_DIR):
run("chmod 755 AWS_Resources/main.sh")
run(". AWS_Resources/main.sh", shell=False)
# When you use shell=false method 'run' will execute the command string without a shell interpreter prefix:
get("log.log", ".")
get("magneto_poc/magneto_reports/BVT_magneto*", ".") # Get the generated report as wel
更奇怪的是,我在日志中得到关注
[18.130.152.254] out: Installing collected packages: certifi, chardet, idna, urllib3, requests, docutils, jmespath, six, python-dateutil, botocore, colorama, s3transfer, pyasn1, rsa, PyYAML, **awscli, boto3**, docopt
[18.130.152.254] out: Successfully installed PyYAML-3.11 **awscli boto3** botocore certifi chardet-2.3.0 colorama docopt docutils idna-2.0 jmespath pyasn1-0.1.9 python-dateutil requests-2.9.1 rsa s3transfer six-1.10.0 urllib3-1.13.1
如果登录ec2实例后执行相同的操作, 一切都像魅力。 该错误消失,环境变量设置正确。
可能是什么问题?