0

I have made the following subprocess to interact with the yowsup-cli.

connection_string = "python /root/yowsup/yowsup-cli demos --yowsup --config config.json"
popen_parameters = connection_string.split(" ")
proc = Popen(popen_parameters, stdout=PIPE, stderr=PIPE)

out, err = proc.communicate()

The interaction works fine I am able to send parameters but I have no return from the CLI of the yowsup-cli. the return is working in the background.
I need to send some variables from the input and receive the result from yowsup-cli.

41 72 6c
  • 1,600
  • 5
  • 19
  • 30
sinaps1
  • 57
  • 9

1 Answers1

0

I used Pexpect and create a algorithm to reach my goal. For those who will need to create an automation here is what I used:

child = pexpect.spawn('/bin/bash')
fout = open('mylog.txt','wb')
child.logfile = fout

child.sendline('/usr/bin/python /root/yowsup/yowsup-cli demos --yowsup --config config.json')
child.expect('offline') 

The trick was to create a bash child process before running python script.

After the last line the child.expect('offline') you can send the desired commands in a logic that will fit your porpoise.

Hope this help others

sinaps1
  • 57
  • 9