subprocess.run不能获得所有输出

环境win10 vscode/idle

import subprocess

def runcommand():

    cmd= "python3 C:/Users/user/Desktop/sqlmap/sqlmap.py -u http://testphp.vulnweb.com/listproducts.php?cat=1"+" --dbs -v0 -batch"

    print(cmd)
    cmd_result = subprocess.run(cmd,shell=True,capture_output=True,text=True)
    output = cmd_result.stdout
    print(output)

if __name__ == "__main__":

    runcommand()


不知道为何卡在开始的start 我曾经把代码发给朋友 他可以正常运行

目标:这是正常运行的输出界面

我曾经在虚拟机也运行过 但也卡在start 之前这代码我也是可以正常运行的 我可以确定路径是对的 所以朋友认为是我电脑的问题 是电脑的設定问题 ?有人知道原因嗎
试过把代码cmd=”ipconfig” subprocess.run 也是可以正常运行的 都可以看到所有输出 但最近不知啥原因卡在start了
试过把python3 C:/Users/user/Desktop/sqlmap/sqlmap.py -u testphp.vulnweb.com/listproducts.ph... –dbs -v0 -batch 直接放在cmd也是可以运行的 像图2的右方输出一樣
尝试了這樣,都不行 也是卡在start

    cmd_result = subprocess.run(
    cmd, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    print(cmd_result.stdout)

我又开了新的虚拟机 把代码放进去 在虚拟机又正常运作了 但我的主电脑还是不能运作 原因是?


上面是主电脑的sqlmap
*不是代码的问题

這error和我的sqlmap輸出停在start有关嗎?

Jason990420
最佳答案

Upgrade the version of your python and sqlmap (1.6.3) ?
还有, 看来你执行的环境不一样

2年前 评论
BenWong8976797 (楼主) 2年前
讨论数量: 4
Jason990420

Got different result as yours when run your code in my PyScripter, the scrpt is blocked there and nothing happened.

Maybe you can try to add following option when call subprocess.run ?

  • stdin=subprocess.PIPE or
  • input='Y'
2年前 评论
BenWong8976797 (楼主) 2年前
Jason990420

Upgrade the version of your python and sqlmap (1.6.3) ?
还有, 看来你执行的环境不一样

2年前 评论
BenWong8976797 (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!