def index():
    ....
    return dict(message=message)

and the view should be
{{extend 'layout.html'}}
<pre>{{=message}}</pre>

On Mar 2, 10:56 pm, Babu <[email protected]> wrote:
> Sorry, I am new to python and web2py.  I am running a python script to
> get multiline output of 'ifconfig' but I am not able to print it in
> multiline through view.  My stand alone script works fine..
>
> Here is controller..
> def index():
>     import paramiko
>     import os
>
>     hostname = '<hostname>'
>     port = 22
>     username ='root'
>
>     paramiko.util.log_to_file('/var/tmp/paramiko.log')
>     s = paramiko.SSHClient()
>     s.load_system_host_keys()
>     s.connect(hostname, port, username)
>     stdin, stdout, stderr = s.exec_command('ifconfig -a')
>     message = stdout.readlines()
>     s.close()
>     return message
>
> here is my view:
> {{extend 'layout.html'}}
> <h1>This is the ifconfig/index.html template</h1>
> {{=BEAUTIFY(response._vars)}}
> {{=message}}
>
> Here is the output:
> eth0 Link encap:Ethernet HWaddr 00:11:0A:55:25:12 BROADCAST MULTICAST
> MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0
> txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Base address:
> 0x5000 Memory:fdfe0000-fe000000 eth1 Link encap:Ethernet HWaddr
> 00:11:0A:55:25:13 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0
> errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0
> overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b)
> TX bytes:0 (0.0 b) Base address:0x5040 Memory:fdf60000-fdf80000 eth2
> Link encap:Ethernet HWaddr 00:11:85:E7:67:AF inet
> addr:xxx.xxxx.xxxx.xxx Bcast:xxx.xxxx.xxx.255 Mask:255.255.255.0 UP
> BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1057247994
> errors:0 dropped:0 overruns:0 frame:0 TX packets:1251720 errors:0
> dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:
> 667206916895 (621.3 GiB) TX bytes:323342695 (308.3 MiB) Interrupt:233
> eth3 Link encap:Ethernet HWaddr 00:11:85:E7:67:AE BROADCAST MULTICAST
> MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0
> txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:50 lo
> Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP
> LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:10655273 errors:0
> dropped:0 overruns:0 frame:0 TX packets:10655273 errors:0 dropped:0
> overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1658158195
> (1.5 GiB) TX bytes:1658158195 (1.5 GiB)
>
> I want to get the output the following way:
> eth0      Link encap:Ethernet  HWaddr 00:11:0A:55:25:12
>           BROADCAST MULTICAST  MTU:1500  Metric:1
>           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
>           Base address:0x5000 Memory:fdfe0000-fe000000
>
> ....
> ....
>
> Thanks for the help

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to