Commit 4300c557 authored by anonym's avatar anonym
Browse files

Actually VMCommand supports multi-line commands.

This will greatly speed up VM.file_{append,overwrite}() and in
particular make it much faster to transfer Dogtail scripts.
parent 63820fe5
......@@ -18,8 +18,6 @@ class VMCommand
end
end
# The parameter `cmd` cannot contain newlines. Separate multiple
# commands using ";" instead.
# If `:spawn` is false the server will block until it has finished
# executing `cmd`. If it's true the server won't block, and the
# response will always be [0, "", ""] (only used as an
......
......@@ -517,12 +517,12 @@ EOF
end
def file_append(file, lines, user = 'root')
lines = lines.split("\n") if lines.class == String
lines.each do |line|
cmd = execute("echo '#{line}' >> '#{file}'", :user => user)
assert(cmd.success?,
"Could not append to '#{file}':\n#{cmd.stdout}\n#{cmd.stderr}")
end
lines = lines.join("\n") if lines.class == Array
# Use some tricky quoting to allow any character to be appended
lines.gsub!("'", "'\"'\"'")
cmd = execute("echo '#{lines}' >> '#{file}'", :user => user)
assert(cmd.success?,
"Could not append to '#{file}':\n#{cmd.stdout}\n#{cmd.stderr}")
end
def file_overwrite(*args)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment