How can I do this with python ?

X

Xiao Jianfeng

Dear all,

In a shell script, I can run a command which need interactive input like
this,

#!/bin/sh

A_Command<<-EOF
a
b
c
EOF

But, how can I do this with python ?

Thanks in advance.
 
T

Tim N. van der Leeuw

Your question is insufficiently clear for me to answer.

Do you want to know how to read from standard-input in a Python
program?

Do you want to know how to start an external program from Python, and
then connect something to that programs standard input?

Do you want to know something else?

Please specify!

Cheers,

--Tim
 
X

Xiao Jianfeng

Tim said:
Your question is insufficiently clear for me to answer.

Do you want to know how to read from standard-input in a Python
program?

Do you want to know how to start an external program from Python, and
then connect something to that programs standard input?

Do you want to know something else?

Please specify!

Cheers,

--Tim
Thanks.

For example, I can call vim and do something like this in a shell script,

#!/bin/sh

vim a.file<<-EOF
:some_vim_command
:some_vim_command
:w
:q
EOF

I want to know how to call vim and to the same thing with python.

Regrads,
 
P

Philippe Martin

Xiao said:
Thanks.

For example, I can call vim and do something like this in a shell script,

#!/bin/sh

vim a.file<<-EOF
:some_vim_command
:some_vim_command
:w
:q
EOF

I want to know how to call vim and to the same thing with python.

Regrads,

hi,

os.popen should do that.

Philippe
 
H

Harold Fellermann

Better go for the subprocess module. It is supposed to replace os.popen
and has a much nicer interface.

- harold -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,213
Latest member
DonnellTol

Latest Threads

Top