Backtick probleme

Hey guys i got a probleme with this code :
out = ls
puts out

When i run it i got :
C:/Users/Xcoder/Documents/NetBeansProjects/Learnerr/lib/Sys.rb:1:in ``’:
No such
file or directory - ls (Errno::ENOENT)
from
C:/Users/Xcoder/Documents/NetBeansProjects/Learnerr/lib/Sys.rb:1:in
`’
Thanks for help !

Am 02.07.2013 15:54, schrieb xcoder Blue_fox:

Hey guys i got a probleme with this code :
out = ls
puts out

When i run it i got :
C:/Users/Xcoder/Documents/NetBeansProjects/Learnerr/lib/Sys.rb:1:in ``’:
No such
file or directory - ls (Errno::ENOENT)

Looks like a Windows system… maybe this works:

out = dir

On Tue, Jul 2, 2013 at 8:54 AM, xcoder Blue_fox
[email protected]wrote:

`’
Thanks for help !

If your computer doesn’t have an ls command, you can do the same thing
from
Ruby with Dir.pwd

-Josh

On Tue, Jul 2, 2013 at 4:26 PM, Josh C. [email protected] wrote:

    from

C:/Users/Xcoder/Documents/NetBeansProjects/Learnerr/lib/Sys.rb:1:in
`’
Thanks for help !

If your computer doesn’t have an ls command, you can do the same thing
from Ruby with Dir.pwd

I guess you rather mean Dir.entries(‘.’) or Dir[“*”].

Cheers

robert

On Tue, Jul 2, 2013 at 6:54 AM, xcoder Blue_fox [email protected]
wrote:

Hey guys i got a probleme with this code :
out = ls
puts out

No, you have two other problems:

  1. cargo-culting example code for a different platform without
    understanding what it’s doing.

  2. running a system command from ruby without running that
    command from a shell to confirm that it works as expected.

Both should be pretty easy to fix :slight_smile:

On Tue, Jul 2, 2013 at 11:44 AM, Robert K.
[email protected]wrote:

If your computer doesn’t have an ls command, you can do the same thing

from Ruby with Dir.pwd

I guess you rather mean Dir.entries(‘.’) or Dir[“*”].

Yes, thank you!

-Josh