# can decide whether wait or not
def Utils.execute_shell_with_log(cmd, log_path, wait=true)
- # call execute
- cmd = "'#{File.dirname(__FILE__)}/execute_with_log' '#{cmd}' '#{log_path}'"
+ if get_os_category( HOST_OS ) != "windows" then
+ # call execute
+ cmd = "'#{File.dirname(__FILE__)}/execute_with_log' '#{cmd}' '#{log_path}'"
- # generate command
- cmd = generate_shell_command(cmd, nil)
+ # generate command
+ cmd = generate_shell_command(cmd, nil)
- # print log
- pipe = IO.popen("#{cmd} 2>&1")
- if wait then
- return Process.waitpid2(pipe.pid)
+ # print log
+ pipe = IO.popen("#{cmd} 2>&1")
+ if wait then
+ return Process.waitpid2(pipe.pid)
+ else
+ return [pipe.pid,nil]
+ end
else
- return [pipe.pid,nil]
+ # create logger
+ log = Logger.new(log_path)
+
+ IO.popen("#{cmd} 2>&1") { |io|
+ io.each { |line|
+ log.info line
+ }
+ }
+
+ # return exit code
+ return [nil, $?]
end
end