Rev 24866 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#-*- perl -*-# Copyright (C) 2000-3 R Development Core Team## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful, but# WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# General Public License for more details.## A copy of the GNU General Public License is available via WWW at# http://www.gnu.org/copyleft/gpl.html. You can also obtain it by# writing to the Free Software Foundation, Inc., 59 Temple Place,# Suite 330, Boston, MA 02111-1307 USA.# Send any bug reports to r-bugs@r-project.orguse File::Basename;#use R::Utils;my $revision = ' $Revision: 1.5 $ ';my $version;my $name;$revision =~ / ([\d\.]*) /;$version = $1;($name = $0) =~ s|.*/||;my $R_opts = "--restore --save";sub R_version {my ($name, $version) = @_;print STDERR <<END;$name $versionCopyright (C) 1997-2003 R Core Development Team.This is free software; see the GNU General Public Licence version 2or later for copying conditions. There is NO warranty.ENDexit 0;}while(defined($arg = shift @ARGV)){if ($arg eq "-h" || $arg eq "--help") {usage(); exit 0;}if ($arg eq "-v" || $arg eq "--version") {R_version($name, $version); exit 0;}if ($arg eq "--") {last;}if ($arg =~ /^-/) {$R_opts .= " " . $arg;} else {unshift @ARGV, $arg;last;}}my $infile = shift @ARGV;usage() unless defined $infile;my $outfile = shift @ARGV;$outfile = basename($infile, ".R"). ".Rout" unless defined $outfile;die "input file `$infile' cannot be opened\n" unless -f ${infile};my $cmd ="Rterm.exe $R_opts < $infile > $outfile";## W95's command.com cannot redirect stderr$cmd .= " 2>&1" if $ENV{"ComSpec"} =~ /cmd.exe$/;system($cmd);sub usage {print STDERR <<END;Usage: Rcmd BATCH [options] infile [outfile]Run R non-interactively with input from infile and place output (stdoutand stderr) to another file. If not given, the name of the output fileis the one of the input file, with a possible \`.R\' extension stripped,and \`.Rout\' appended.Options:-h, --help print short help message and exit-v, --version print version info and exit-- end processing of optionsFurther arguments starting with a \`-\' are considered as options as longas \`--\' was not encountered, and are passed on to the R process, whichby default is started with \`--restore --save\'.Report bugs to <r-bugs\@r-project.org>.ENDexit 0;}