You could do
echo -e "import sys\nfor r in range(10): print 'rob'" | python
Or without pipes:
python -c "exec(\"import sys\nfor r in range(10): print 'rob'\")"
Or
(echo "import sys" ; echo "for r in range(10): print 'rob'") | python
More Related Contents:
- ‘yes’ reporting error with subprocess communicate()
- Calling a python script from command line without typing “python” first
- How to run a python script from IDLE interactive shell?
- Command line execution in different folder
- Enhancement of unix script [closed]
- Execute python script while open terminal
- Running shell command and capturing the output
- Some Unix commands fail with ” not found”, when executed using Python Paramiko exec_command
- How to save a Python interactive session?
- Seeing escape characters when pressing the arrow keys in python shell
- How do I pipe a subprocess call to a text file?
- Is there any simple way to benchmark Python script?
- syntax error when using command line in python
- How can I overwrite/print over the current line in Windows command line?
- Executing command line programs from within python [duplicate]
- How do I make a python script executable?
- Call Python script from bash with argument
- Why is an MD5 hash created by Python different from one created using echo and md5sum in the shell?
- How to make a python, command-line program autocomplete arbitrary things NOT interpreter
- How to easily print ascii-art text? [closed]
- Passing a List to Python From Command Line
- When to use Shell=True for Python subprocess module [duplicate]
- Implement an interactive shell over ssh in Python using Paramiko?
- Read from File, or STDIN
- How to repeat last command in python interpreter shell?
- Why does subprocess.Popen() with shell=True work differently on Linux vs Windows?
- assigning value to shell variable using a function return value from Python
- A Python script that activates the virtualenv and then runs another Python script?
- subprocess call ffmpeg (command line)
- run python script directly from command line