代码之家  ›  专栏  ›  技术社区  ›  DimiDak

python中有与bash的“set-x”等价的东西吗?

  •  1
  • DimiDak  · 技术社区  · 4 年前

    我只找到了这样的东西 python3 -m pdb myscript.py 但它不做什么 set -x 执行脚本,并在终端上显示用变量的实际值执行的每一行。

    例如:

    #!/bin/bash
    set -x
    echo "This is a foo message"
    sshpass -p $2 ssh root@$1
    echo "this is just argument no3 --> $3 :)"
    

    因此,当您使用参数运行脚本时,您会看到具体完成了什么。

    root@notebook:~# ./myscript.sh myserver.com mypassword bar
    
    + echo 'This is a foo message'
    This is a foo message
    
    + sshpass -p mypassword ssh root@myserver.com
    
    + echo "this is just argument no3 --> bar :)"
    this is just argument no3 --> bar :)
    
    1 回复  |  直到 4 年前
        1
  •  1
  •   IronMan    4 年前

    是的,嗨,也许用 python -m trace -t myscript.py 会给你看你感兴趣的痕迹。