<br>Are you new to Python?<br><br>Ipython is shell for python . ofcoz you can run the bash script directly under python.<br><br><br>#!/usr/bin/python<br><br>import os<br>p=os.popen("./report.sh")<br>print p.strip('/n')<br>
<br><br><div class="gmail_quote">On Sun, Oct 26, 2008 at 7:21 PM, ferrety ferrety <span dir="ltr"><<a href="mailto:yferrety@gmail.com">yferrety@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi List,<br>
<br>
I'm new to IPython, I just discovred it ysterday and I was surprised<br>
bu its powerfullness.<br>
So, let's suppose the following shell script (report.sh). It's simply<br>
output the IP adresses of my box<br>
and some other stuffs and it's called as a "cron" job each 5 minutes.<br>
<br>
-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8<br>
#!/usr/bin/env bash<br>
OS=`uname`<br>
IO="" # store IP<br>
<br>
case $OS in<br>
Linux) IP=`ifconfig | grep 'inet addr:'| grep -v '<a href="http://127.0.0.1" target="_blank">127.0.0.1</a>' |<br>
cut -d: -f2 | awk '{ print $1}'`;;<br>
<br>
FreeBSD|OpenBSD|Darwin) IP=`ifconfig | grep -E 'inet.[0-9]' |<br>
grep -v '<a href="http://127.0.0.1" target="_blank">127.0.0.1</a>' | awk '{ print $2}'` ;;<br>
<br>
SunOS) IP=`ifconfig -a | grep inet | grep -v '<a href="http://127.0.0.1" target="_blank">127.0.0.1</a>' | awk '{<br>
print $2} '` ;;<br>
*) IP="Unknown";;<br>
esac<br>
# other stuffs here ...<br>
echo "$IP"<br>
<br>
-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8<br>
<br>
Now, I'd like to change this bash script and move to an IPython version of it.<br>
I can easily start with:<br>
<br>
-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8<br>
<br>
$ ipython -p sh<br>
Leopard libedit detected.<br>
IPython 0.9.1 [on Py 2.5.1]<br>
<br>
[/tmp]|1> !./report.sh<br>
<a href="http://192.168.1.3" target="_blank">192.168.1.3</a><br>
<a href="http://10.37.129.2" target="_blank">10.37.129.2</a><br>
<a href="http://10.211.55.2" target="_blank">10.211.55.2</a><br>
[/tmp]|2><br>
<br>
-8-8-8-8 snip -8-8-8-8 snip -8-8-8-8<br>
<br>
But how can I save this in a session (i.e file on disk) to be able to<br>
reply that session as a "cron" job (not manually)?<br>
<br>
Advices will be very welcome.<br>
<br>
Regards<br>
Ferret<br>
_______________________________________________<br>
IPython-user mailing list<br>
<a href="mailto:IPython-user@scipy.org">IPython-user@scipy.org</a><br>
<a href="http://lists.ipython.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://lists.ipython.scipy.org/mailman/listinfo/ipython-user</a><br>
</blockquote></div><br>