Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我执行子进程以成功运行vpn程序,但将这些进程封装到函数中,然后调用它失败_Python 3.x - Fatal编程技术网

Python 3.x 我执行子进程以成功运行vpn程序,但将这些进程封装到函数中,然后调用它失败

Python 3.x 我执行子进程以成功运行vpn程序,但将这些进程封装到函数中,然后调用它失败,python-3.x,Python 3.x,为什么封装的函数无法再次调用子进程?执行过程语句时没有问题 过程语句的成功执行,例如 vpn_config = """ /opt/cisco/anyconnect/bin/vpn -s connect host <<"EOF" 0 user.name Password y EOF """ subprocess.run(vpn_config, shell=True) 我想问一下原因是什么,我也尝

为什么封装的函数无法再次调用子进程?执行过程语句时没有问题

过程语句的成功执行,例如

vpn_config = """
/opt/cisco/anyconnect/bin/vpn -s connect host  <<"EOF"
0
user.name
Password
y
EOF
"""
    subprocess.run(vpn_config, shell=True)
我想问一下原因是什么,我也尝试过pritf来运行管道角色,但也失败了

def vpn_connect():
    vpn_config = """
    /opt/cisco/anyconnect/bin/vpn -s connect host  <<"EOF"
    0
    user.name
    Password
    y
    EOF
    """
    subprocess.run(vpn_config, shell=True)

Cisco AnyConnect Secure Mobility Client (version 4.8.00175) .

Copyright (c) 2004 - 2019 Cisco Systems, Inc.  All Rights Reserved.


  >> state: Disconnected
  >> state: Disconnected
  >> notice: Ready to connect.
  >> registered with local VPN subsystem.
  >> contacting host (vpn-hz.didichuxing.com) for login information...
  >> notice: Contacting vpn-hz.didichuxing.com.

  >> Connection Banner
  >> Username:请输入您的邮箱前缀
Password:请输入邮箱密码

  >> Please enter your username and password.
    0) 01_Normal
    1) 02_SYSOP
    2) 03_Intern_Nomal(SXYGBO)
    3) 04_Intern_SYSOP(SXYGBOS)
    4) 05_Outsourcing_Nomal(HYJC)
    5) 06_Outsourcing_SYSOP(WBYG)
    6) 07_CTEAM
    7) 08_WBKF
    8) 09_American-R&D
    9) 10_SYSOTN
    10) 11_SYSAW
    11) 98_vpn_back
    12) 99_taxis
    13) D_Normal
    14) Mexco_CSC
    15) Normal-test
    16) SYSOP_Backup
    17) X-modem
Group: [01_Normal]     0

Username: [xxx]    xxx
** unable to get tty! (using stdin), password will echo **
Password: 
  >> Connection Banner
  >> Username:请输入您的邮箱前缀
Password:请输入邮箱密码


  >> Login failed.