[IPython-user] Bash shell scripts to IPython scripts

ferrety ferrety yferrety@gmail....
Sun Oct 26 14:21:47 CDT 2008

Hi List,

I'm new to IPython, I just discovred it ysterday and I was surprised
bu its powerfullness.
So, let's suppose the following shell script (report.sh). It's simply
output the IP adresses of my box
and some other stuffs and it's called as a "cron" job each 5 minutes.

-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8
#!/usr/bin/env bash
IO="" # store IP

case $OS in
    Linux) IP=`ifconfig  | grep 'inet addr:'| grep -v '' |
cut -d: -f2 | awk '{ print $1}'`;;

    FreeBSD|OpenBSD|Darwin) IP=`ifconfig  | grep -E 'inet.[0-9]' |
grep -v '' | awk '{ print $2}'` ;;

    SunOS) IP=`ifconfig -a | grep inet | grep -v '' | awk '{
print $2} '` ;;
    *) IP="Unknown";;
# other stuffs here ...
echo "$IP"

-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8

Now, I'd like to change this bash script and move to an IPython version of it.
I can easily start with:

-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8

$ ipython -p sh
Leopard libedit detected.
IPython 0.9.1   [on Py 2.5.1]

[/tmp]|1> !./report.sh

-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8

But how can I save this in a session (i.e file on disk) to be able to
reply that session as a "cron" job (not manually)?

Advices will be very welcome.


More information about the IPython-user mailing list