Hi,
im trying to execute multiple cmds in a method that use the same view
which
has multiple calls to the same partial inside it.
However i cant get it to work correctly, so any help here would be
appreciated
heres the controller code
def index
cmd_df = "df -Ph"
exec_cmd(cmd_df)
cmd_sys = "uname -a"
exec_cmd(cmd_sys)
end
private
def exec_cmd(cmd)
r=IO.popen(cmd, "r")
@result = r.readlines($/)
r.close_read
return @result
end
heres the index view
<div class="body_top">
<%= render_partial ''shared/page_header_image'',
''image'' =>
''/images/system.gif'' %>
<%= render_partial ''shared/page_menu'' %>
</div> <!-- body_top -->
<div class="body_content">
<h1>Overview</h1>
<%= render_partial ''shared/grid'',
''title'' => ''Filesystems''
,''cols'' => 6 %>
<h3>System</h3>
<%= render_partial ''shared/grid'',
''title'' => ''System''
,''cols''
=> 2 %>
</div><!-- body_content -->
& finally heres the _grid partial
<table>
<th width="10%", colspan=<%= cols %>><%= title
%></th>
<% for r in @result %>
<tr class="<%= cycle("even", "odd")
%>">
<% for s in r.split('' '', cols) %>
<td><%= s %> </td>
<% end %>
</tr>
<br>
<% end %>
</table>
--
Posted via http://www.ruby-forum.com/.