+++ /dev/null
-#!/usr/bin/ruby
-
-require 'logger'
-
-# parse arguments
-cmd = ARGV[0]
-log_path = ARGV[1]
-
-# if log path specified, generate log
-if not log_path.nil? then
- # create logger
- log = Logger.new(log_path)
-
- # execute and write log
- IO.popen("#{cmd} 2>&1") { |io|
- io.each { |line|
- log.info line
- }
- }
-
- # return exit code
- exit $?.exitstatus
-#$?.to_i
-else
- # execute command & wait
- pipe = IO.popen("#{cmd}")
- pid, status = Process.waitpid2(pipe.pid)
-
- # return exit code
- if pid.nil? or status.nil? then
- exit 1
- else
- exit status.exitstatus
- end
-end
--- /dev/null
+#!/usr/bin/ruby
+=begin
+
+ execute_with_log.rb
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
+require 'logger'
+$LOAD_PATH.unshift File.dirname(__FILE__)
+require 'utils.rb'
+
+# parse arguments
+cmd = ARGV[0]
+log_path = ARGV[1]
+
+# create logger
+log = Logger.new(log_path)
+
+# generate command
+cmd = Utils.generate_shell_command(cmd, nil)
+
+# execute and write log
+IO.popen("#{cmd} 2>&1") { |io|
+ io.each { |line|
+ log.info line
+ }
+}
+
+# return exit code
+exit $?.exitstatus
Contributors:
- S-Core Co., Ltd
=end
+require 'rbconfig'
class Utils
STARTUP_INFO_SIZE = 68
# can decide whether wait or not
def Utils.execute_shell_with_log(cmd, log_path, wait=true)
- if get_os_category( HOST_OS ) != "windows" then
- # call execute
- cmd = "'#{File.dirname(__FILE__)}/execute_with_log' '#{cmd}' '#{log_path}'"
+ ruby_path=File.join(Config::CONFIG["bindir"],
+ Config::CONFIG["RUBY_INSTALL_NAME"] +
+ Config::CONFIG["EXEEXT"])
- # generate command
- cmd = generate_shell_command(cmd, nil)
-
- # print log
- pipe = IO.popen("#{cmd} 2>&1")
- if wait then
- return Process.waitpid2(pipe.pid)
- else
- return [pipe.pid,nil]
- end
- else
- # create logger
- log = Logger.new(log_path)
+ # call execute
+ os_category = get_os_category( HOST_OS )
+ if os_category == "windows" then
+ cmd = cmd.gsub("\"", "\\\"")
+ end
- IO.popen("#{cmd} 2>&1") { |io|
- io.each { |line|
- log.info line
- }
- }
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/execute_with_log.rb\" \"#{cmd}\" \"#{log_path}\""
- # return exit code
- return [nil, $?]
+ # print log
+ pipe = IO.popen("#{cmd} 2>&1")
+ if wait then
+ return Process.waitpid2(pipe.pid)
+ else
+ return [pipe.pid,nil]
end
end