Reputation: 1399
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
Upvotes: 0
Views: 218
Reputation: 51181
You generate your commands inproperly. It should be:
command = 'ls -al ' + path
Upvotes: 2