Reputation: 736
I try to do it this way, but nothing happens.
Process.new("app_name >> app_name.log")
What is the proper syntax?
Upvotes: 1
Views: 327
Reputation: 3175
You can do this entirely within Crystal without spawning a shell using the output
option of Process.new
.
File.open("app_name.log", "a") do |file|
Process.new("app_name", output: file)
end
Upvotes: 6
Reputation: 5661
Process.new
by default executes the given command directly without a shell, therefore shell extensions like pipes do not work. But it accepts an argument shell
, which executes the command with /bin/sh
if set to true
.
Process.new("app_name >> app_name.log", shell: true)
Upvotes: 3