Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:21:50+00:00 2026-06-11T08:21:50+00:00

Possible Duplicate: how to write in stdout after to call a method (doing a

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:21:52+00:00Added an answer on June 11, 2026 at 8:21 am

    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 pexpect module 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:

    import pexpect
    
    child = pexpect.spawn('myAPNscript.py')
    child.expect('Enter PEM pass phrase:.*')
    child.sendline('FOO')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why split the <script> tag when writing it with document.write()? Browsing through
Possible Duplicate: Invalid read/write sometimes creates segmentation fault and sometimes does not I have
Possible Duplicate: Oracle DB: How can I write query ignoring case? I have an
Possible Duplicate: Do write-only properties have practical applications? A getter without a setter makes
Possible Duplicate: Is it possible to write swap method in Java? Given two values
Possible Duplicate: Writing C# Plugin System Is it possible to write a program that
Possible Duplicate: Why split the <script> tag when writing it with document.write()? Looking at
Possible Duplicate: Why write <script type=“text/javascript”> when the mime type is set by the
Possible Duplicate: Can I write native iPhone apps using Python I just googled whether
Possible Duplicate: Read/Write Python Closures In the following function, the internal function does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.