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
`<main>'
Thanks for help !

···

--
Posted via http://www.ruby-forum.com/.

Looks like a Windows system... maybe this works:

   out = `dir`

···

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)

--
<https://github.com/stomar/&gt;

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 8:54 AM, xcoder Blue_fox <lists@ruby-forum.com>wrote:

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
`<main>'
Thanks for help !

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 6:54 AM, xcoder Blue_fox <lists@ruby-forum.com> wrote:

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

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan

I guess you rather mean Dir.entries('.') or Dir["*"].

Cheers

robert

···

On Tue, Jul 2, 2013 at 4:26 PM, Josh Cheek <josh.cheek@gmail.com> wrote:

On Tue, Jul 2, 2013 at 8:54 AM, xcoder Blue_fox <lists@ruby-forum.com>wrote:

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
`<main>'
Thanks for help !

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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Yes, thank you!

-Josh

···

On Tue, Jul 2, 2013 at 11:44 AM, Robert Klemme <shortcutter@googlemail.com>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["*"].