[IPython-user] ipython to replace bash scripts?

Ville M. Vainio vivainio@gmail....
Wed Dec 9 11:18:51 CST 2009


On Wed, Dec 9, 2009 at 7:09 PM, Florian Lindner <mailinglists@xgm.de> wrote:

> - Is ipython -p sh the right interpreter to start? My first try to do
> something bash like was:
>
> #!/usr/bin/ipython -p sh
>
> a = !ls
>
> (called from bash) but it resulted in:
>
> ImportError: Import by filename is not supported.

You can "force" the sh profile by adding "import ipy_profile_sh.py" to
your ipy_user_conf.py. Note that sh profile doesn't work on ipython
0.10, you need 0.9.1 or older.

> - Or should I use normal python for these kind of scripts?

For easier maintenance, probably.

> all this stuff with python but it is not so well integrated. Therefore I hope
> that ipython could provide something to work this way? I have already seen
> things like !ls for getting the output and the SLists. What is right way to
> use them non-interactively?

I have extracted the SList class for plain-python use exactly for this
purpose, it's available in "sloppycode" launchpad project.

You can grab stringlist.py from

http://bazaar.launchpad.net/~villemvainio/sloppycode/trunk/files/head:/sloppycode/

Using that, you can do l = shcmd("ls") instead of l = !ls

-- 
Ville M. Vainio
http://tinyurl.com/vainio


More information about the IPython-user mailing list