0

I need to run a bash command (ls -al) in my ruby script. This command is launched in different folders that start with the letters "my".

Dir.glob("#{PATH_TO_SEARCH}/my*",File::FNM_CASEFOLD) do |path|

    command = path + "/ls -al"
    output_result = (%x(#{command}))

end

I receive a strange error:

"command not found: /home/user/my123/ls -al"
"command not found: /home/user/my222/ls -al"
"command not found: /home/user/my423/ls -al"

The iteration goes well. The problem is the command

1 Answer 1

2

You generate your commands inproperly. It should be:

command = 'ls -al ' + path
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.