Created
March 11, 2014 05:09
-
-
Save suxue/9479817 to your computer and use it in GitHub Desktop.
inter-operation between python and shell by using ipython script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ipython | |
# vim: ft=python: | |
# to run it as ipython script, suffix must be .ipy | |
tmpfile = !mktemp | |
tmpfile = tmpfile[0] | |
files = !ls | |
file = open (tmpfile, "w") | |
file.writelines(files.n) # get it as newline separated string | |
file.close() | |
!cat $tmpfile # refer to python variable in shell | |
!echo | |
!rm $tmpfile # equals %sc rm $tmpfile | |
!echo $$HOME # REFER to shell variable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment