Menu

#14 Having stdin parameter to startProcess method is very useful

open
None
5
2013-05-10
2013-05-09
raghavender
No

startProcess method does not have an stdin parameter. It is very useful to have.

Discussion

  • Moray Grieve

    Moray Grieve - 2013-05-09

    Hi - the ProcessWrapper object returned by startProcess() has a write method that allows you to write to it's stdin. Is this not what you need?

     
  • Moray Grieve

    Moray Grieve - 2013-05-09

    If you have a look at the pysys-examples, PySys_internal_023, there is an example of doing this;

        self.hprocess = self.startProcess(command=sys.executable,
                          arguments = [script, "3"],
                          environs = os.environ,
                          workingDir = self.output,
                          stdout = "%s/reader.out" % self.output,
                          stderr = "%s/reader.err" % self.output,
                          state=BACKGROUND)
    
        # write to the process stdin
        self.log.info("Writing to the process stdin")
        self.hprocess.write("The cat sat on the mat\n")
    
     
  • raghavender

    raghavender - 2013-05-10

    The requirement here is as follows.

    Sybase ESP applications can be managed by using the an admin tool as follows. All commands to be executed can be written in a text file and can be given to that tool as follows. Then it executes commands one by one.

    esp_cluster_admin < installApp.txt

    As stdin parameter is not available for startprocess, it is achieved by using the subprocess.popen as follows. It has stdin parameter.

    fd_in = open('installApp.txt','r')
    subprocess.Popen(args=[self.sbadminToolPath,stdin=fd_in,.....)

     

    Last edit: Moray Grieve 2013-05-10
  • Moray Grieve

    Moray Grieve - 2013-05-10

    I understand that you might want something more advanced in terms of pipes so this is a valid request, but you can achieve this already, i.e.

    hprocess = self.startProcess(...)

    fp = open('installApp.txt', 'r')
    for line in fp.readlines():
    hprocess.write(line)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.