1184N/A#!/usr/bin/env ruby
1472N/A#
1184N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
1184N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1184N/A#
1184N/A# This code is free software; you can redistribute it and/or modify it
1472N/A# under the terms of the GNU General Public License version 2 only, as
1184N/A# published by the Free Software Foundation. Oracle designates this
1472N/A# particular file as subject to the "Classpath" exception as provided
1184N/A# by Oracle in the LICENSE file that accompanied this code.
1184N/A#
1184N/A# This code is distributed in the hope that it will be useful, but WITHOUT
1184N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1184N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1184N/A# version 2 for more details (a copy is included in the LICENSE file that
1184N/A# accompanied this code).
1184N/A#
1184N/A# You should have received a copy of the GNU General Public License version
1184N/A# 2 along with this work; if not, write to the Free Software Foundation,
1184N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1472N/A#
1472N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A# or visit www.oracle.com if you need additional information or have any
1184N/A# questions.
1184N/A#
1184N/A#
1184N/A
1184N/Aif ARGV.length < 2
1184N/A puts <<EOF
1184N/AExpects two args: EXEC and OUTPATH. First, it runs and prints
1184N/A`EXEC 2>&1`. If it returns successfully, it writes the output to OUTPATH.
1184N/AThis script will return successfully unless writing the output fails.
1184N/AEOF
1184N/A exit
1184N/Aend
1184N/A
1184N/AEXECPATH = ARGV[0]
1184N/AOUTPATH = ARGV[1]
1184N/A
1184N/Aoutput = `#{EXECPATH}`
1184N/Aputs output
1184N/A
1184N/Aif $?.to_i == 0
1184N/A puts "Writing output of #{EXECPATH} to #{OUTPATH}"
1184N/A File.open(OUTPATH, 'w') {|f| f.write(output) }
1184N/Aelse
1184N/A puts "#{EXECPATH} failed to run trial. Ignoring."
1184N/Aend
1184N/A