Possible Duplicate:
how to write in stdout after to call a method (doing a system of notifications automatic (Iphone))
I have the following script, that I want to execute automatically in a django app. The issue is that it keeps asking for user input.
I would like to know How to pass user input automatically? This is the script:
from apns import APNs, Payload
apns = APNs(use_sandbox=True, cert_file='cert.pem', key_file='key.pem')
# Send a notification
token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87'
payload = Payload(alert="Hello World!", sound="default", badge=1)
my_pass_phrase = 'efisgbieafb3939bg93g238g4792gff9'
apns.gateway_server.send_notification(token_hex, payload)
The issue happens at the following line:
apns.gateway_server.send_notification(token_hex, payload)
The script asks: Enter PEM pass phrase: and waits for user input.
I would like to know how to pass the pass phrase automatically. Thanks in advance!
Because you are using a library and probably don’t have direct access to suppress the asking for user input, what you might have to do in the code that calls this script is use the
pexpectmodule to watch for specific patterns in the output, and then send input appropriately:http://pypi.python.org/pypi/pexpect-u/2.5.1
Examples here: http://www.noah.org/wiki/pexpect
Might be something like: