473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I do this with python ?

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.
May 8 '06 #1
4 1072
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

May 8 '06 #2
Tim N. van der Leeuw wrote:
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,
May 8 '06 #3
Xiao Jianfeng wrote:
Tim N. van der Leeuw wrote:
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,


hi,

os.popen should do that.

Philippe
May 8 '06 #4
Better go for the subprocess module. It is supposed to replace os.popen
and has a much nicer interface.

- harold -

May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Olaf Meyer | last post by:
I'm having some problems compiling Python 2.3.3 on HP-UX (B.11.00). I've tried sevral different options for the configure script (e.g. enabling/disabling gcc, aCC) but I always get the same problem...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 259 open ( -5) / 2573 closed (+17) / 2832 total (+12) Bugs : 745 open ( +0) / 4405 closed (+21) / 5150 total (+21) RFE : 150 open...
1
by: Jerald | last post by:
Running python 2.3.4 on valgrind (a tool like purify which checks the use of uninitialized memory, etc), gives a lot of errors. See below. jfj@cluster:~/> python -V Python 2.3.4...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 241 open ( -6) / 2622 closed (+26) / 2863 total (+20) Bugs : 764 open ( +6) / 4453 closed (+38) / 5217 total (+44) RFE : 150 open...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 391 open ( +7) / 3028 closed (+12) / 3419 total (+19) Bugs : 906 open ( -3) / 5519 closed (+19) / 6425 total (+16) RFE : 207 open...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 420 open ( +4) / 3410 closed ( +2) / 3830 total ( +6) Bugs : 915 open (+17) / 6186 closed ( +6) / 7101 total (+23) RFE : 235 open...
11
by: Osiris | last post by:
I have these pieces of C-code (NOT C++ !!) I want to call from Python. I found Boost. I have MS Visual Studio 2005 with C++. is this the idea: I write the following C source file:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.