1

I wish that, what I input in command line of python/ipython, can also be redirect to a file. Also, I wish to capture the output text to a file.

Is there any option, or internal function could help on this?

Troskyvs
  • 6,313
  • 4
  • 38
  • 91
  • 1
    `python script.py > output.txt` . Linux has also command `tee` to redirect pipe to file and on screen at the same time. `python script.py | tee output.txt` – furas Dec 31 '16 at 01:58
  • you could try `echo "input text" | tee input.txt | python script.py` and also you can `echo "input text" | tee input.txt | python script.py | tee output.txt` – furas Dec 31 '16 at 02:05
  • 1
    Take a look at this [this](http://stackoverflow.com/questions/947810/how-to-save-a-python-interactive-session). It may also be helpful to look into the `sqlite` db that `ipython` creates and updates on your computer. It's usually located at `~/.ipython/profile_default` and is called `history.sqlite`. – Abdou Dec 31 '16 at 02:13

1 Answers1

1

Them simplest way, as "furas" already said is the ">" and "<" symbols. I'm using linux, but as I know, they work in windows too. The syntax you want: python myfile.py < input.txt > output.txt

Sasszem
  • 587
  • 1
  • 5
  • 22