Retreive output of cmd before cmd complete

Help
wagnyun
2012-11-06
2013-06-12
  • wagnyun

    wagnyun - 2012-11-06

    I have two PC, one is local(10.145.27.88), the other is remote PC(10.145.26.135).

    now I want to call a program in remote PC with STAF, eg, the program like 'Ping', the command will be:

    C:\Users\Administrator>staf 10.145.26.135 process  START SHELL COMMAND ping www.google.com RETURNSTDOUT RETURNSTDERR WAIT

    the programe work fine, but it's output, like :
    Response


    {
      Return Code: 1
      Key        : <None>
      Files      : [
        {
          Return Code: 0
          Data       :
    Pinging www.google.com  with 32 bytes of data:

    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.

    Ping statistics for 74.125.128.147:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

        }
        {
          Return Code: 0
          Data       :
        }
      ]
    }

    these message cameout until the program complete, what I want is to retreive the output at real time.

    what's the way to do this?

    I found some idea like use stdout 'filenamepath', this way has two problems for me

    The first is the file was created on remote PC(10.145.26.135), I can't read it directly on local
    The second is the  file operation of serveral loops,

    I use python on windows

    Thank you for your reply!!!

     
  • Sharon Lucas

    Sharon Lucas - 2012-11-06

    See the following forum posting titled "Return data before completion of process" at https://sourceforge.net/projects/staf/forums/forum/104046/topic/2118435.  It contains an example of a STAX job that runs a process on a remote machine and redirects its output to a file (using the STDOUT option) .  In parallel, in a loop to get refrehed stdout data after a delay periode, it submits a STAF FS GET FILE request to get the contents of the STDOUT file on this remote machine.  You could do something similar in Python instead of using STAX.

    I know you didn't want to constantly loop to get updated data but that's the best solution I can offer at this time.  We have a feature open, Feature #523877 "Add open/read/write/close support to FS", that will allow a better implementation (but there's no implementation date yet).  The second phase of this feature will return the file handle(s) for stdin/stdout/stderr when starting a process so that the files can be read and written to outside the process as well.

     

Log in to post a comment.