1

I'm executing this on command line from command line app written in Node:

openapi2apigee generateApi petStore -s '/Users/rafaelpaz/Documents/python/mapping-api_0.0.3.yml' -d /Users/rafaelpaz/Documents/python -D

That basically connects to my google apigee account and generate some files to me locally. After generated the files(with connection still opened from the command line) on terminal I have to enter some inputs end press enter on my keyboard to each of those inputs in order to achieve what I want, which is to deploy those file to my google apigee account (not getting to much into this as it is outside the scope of the question). Here's what I'm talking about:

enter image description here

Would like to know if someone has an example of how to do this automatically on python, I mean entering all those inputs. I'll have a python web app, so this code will be inside an endpoint.

0

1 Answer 1

1

The easiest way to do this is via the calling shell. Where you're using Bash (as we discussed in the comments), you can use a literal heredoc, which feeds multiple lines of input into the process's stdin.

Firstly, a syntax example:

command <<'EOF'
input to command
more input
EOF

So this case:

openapi2apigee generateApi petStore -s '/Users/rafaelpaz/Documents/python/mapping-api_0.0.3.yml' -d /Users/rafaelpaz/Documents/python -D <<'EOF'
https://api.enterprise.apigee.com
[organization]
[user id]
[password]
test
default
EOF
Sign up to request clarification or add additional context in comments.

3 Comments

This does the job in the shell, it's not how you'd do it from within Python itself (which doesn't have a concept of heredocs).
Actually I need this inside python in terminal I can do it actually :(
I too would like to be able to do this in Python. I would think the subprocess module would help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.