Question: For some reason, my @sub\_opps is resulting in:
 ActiveRecord::Relation::ActiveRecord\_Relation\_SubOpp.

This means my .each statement produces nothing, obviously. I've tried multiple things but can't find the correct tweak to make this work.

Any idea why? 

```
def index
    @sub_opps = SubOpp.where("status = ? AND sub_time = ?", false, Date.today)
end

```

To clarify a few things, sub\_time is a column in my SubOpp model and is datetime. Status is boolean. So, i am trying to show SubOpp rows whose status is false and whose datetime is today.

Here is my view.

```
<% @sub_opps.each do |sub_opp| %>
  <%= render sub_opp, :sub_opp => :sub_opp %>
<% end %>

```

Thanks

Answer: 
`os.system()` returns the *exit code* of the process, *not* the result of the `grep` commands. This is always an integer. In the meantime, the output of the process itself is not redirected, so it writes to `stdout` directly (bypassing Python).

You cannot iterate over over an integer.

You should use the [`subprocess.check_output()` function](http://docs.python.org/2/library/subprocess.html#subprocess.check_output) instead if you wanted to retrieve the stdout output of the command.

In this case, you'd be better off using `os.listdir()` and code the whole search in Python instead:

```
for filename in os.listdir('/etc/init.d/'):
    if 'jboss-' in filename and not filename.startswith('jboss-'):
        print filename

```

I've interpreted the `grep -vw jboss-` command as filtering out filenames that *start* with `jboss`; adjust as needed.
The problem is, that `os.system` returns the exit code. If you want to capture the output, you can use [`subprocess.Popen`](http://docs.python.org/2/library/subprocess.html#subprocess.Popen):

```
import subprocess
p = subprocess.Popen("ls", stdout=subprocess.PIPE),
out, err = p.communicate()
files = out.split('\n')

```

Also note that the use of the `subprocess` module is encouraged:

> 
> The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this [`os.system`] function. 
> 
> 
> 

If you do not have to resort to the shell, a pure python solution, as [@Martijn Pieters](https://stackoverflow.com/a/19168388/89391) suggests, seems preferable.