Home  >  Q&A  >  body text

shell - How to pass parameters passed to bash to python starting from the second one

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

扔个三星炸死你扔个三星炸死你2669 days ago1153

reply all(1)I'll reply

  • 学习ing

    学习ing2017-06-28 09:26:40

    #!/bin/bash
    if [ $# -lt 2 ] 
    then
        echo 'Please input more than 2 parameter'
        exit 3
    fi
    
    ALL_PARA=$@
    
    # 自己变通吧, 将下面的语句换成需要执行的python语句
    echo "Python 接受到的参数: ${ALL_PARA:2}"     # 这语法能够获取第二个参数到最后的内容
    
    

    reply
    0
  • Cancelreply