I have just been playing around with IPython. Currently I am wondering how it would be possible to run a shell-command with a python variable within a function. For example:
def x(go):
return !ls -la {go}
x("*.rar")
This gives me “sh: 1: Syntax error: end of file unexpected”. Could anybody please give me a clue on how to let my “x”-function invoke ls like “ls -la *.rar”? There are *.rar files in my working directory.
Thank you in advance,
Rainer
If you look at the
historycommand output, you’ll see that to call external programs ipython uses_ip.systemmethod.Hence, this should work for you:
However, please note that outside ipython you should probably use
subprocess.Popen.