I want show output exit from command.
on my index.html.erb
<%= system("ls /home/username/") %>
Can, help me? i'am new on ruby and rails
I want show output exit from command.
on my index.html.erb
<%= system("ls /home/username/") %>
Can, help me? i'am new on ruby and rails
There's a lot to take into account when running a command like that in a production environment from workers and job queues to validating the machine that will run the command can run it and parsing the response. This type of thing should be done through a model inside a delayed job... but if you just want it to work and don't care about any of that then just do
<%= `ls home/username/` %>
Which will give you the result of running the command. The problem is that system
returns only one of 3 possible values true
false
or nil
and the execution's output is written to std_out.
To get the exit code of the command you run you could do:
<%= system("ls /home/username/"); $? %>
This will print the pid the ls command ran under and the exit status value.