Is this the right way to run a shell script inside Python?

后端 未结 7 393
轮回少年
轮回少年 2021-01-07 16:37
import subprocess
retcode = subprocess.call([\"/home/myuser/go.sh\", \"abc.txt\", \"xyz.txt\"])

When I run these 2 lines, will I be doing exactly t

相关标签:
7条回答
  • 2021-01-07 17:39
    In :call??
    Signature: call(*popenargs, **kwargs)
    Source:   
    def call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete, then
        return the returncode attribute.
    
        The arguments are the same as for the Popen constructor.  Example:
    
        retcode = call(["ls", "-l"])
        """
        return Popen(*popenargs, **kwargs).wait()
    File:      /usr/lib64/python2.7/subprocess.py
    Type:      function
    

    call just invoke Popen,use wait() method wait the popenargs completes

    0 讨论(0)
提交回复
热议问题