shell - How to pass parameters passed to bash to python starting from the second one
扔个三星炸死你
扔个三星炸死你 2017-06-28 09:24:40
0
1
1152
auto.sh
# auto.sh 需要调用3个python脚本1.py 2.py 3.py
用if判断参数进行选择执行哪个脚本

py脚本根据shell脚本传入的参数进行相关操作

Run method

./auto.sh -h 
./auto.sh cc -v 1.0 list 

is how to pass the incoming bash parameters to the python script starting from the second one. The number of parameters passed to python is variable, at least one

扔个三星炸死你
扔个三星炸死你

reply all(1)
学习ing
#!/bin/bash
if [ $# -lt 2 ] 
then
    echo 'Please input more than 2 parameter'
    exit 3
fi

ALL_PARA=$@

# 自己变通吧, 将下面的语句换成需要执行的python语句
echo "Python 接受到的参数: ${ALL_PARA:2}"     # 这语法能够获取第二个参数到最后的内容

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!