[R] calling Perl script from R on Windows 7

Greg Snow Greg.Snow at imail.org
Mon May 24 22:34:50 CEST 2010


Try your same system command, but set intern=TRUE in the call and see if that does what you want.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Harsh
> Sent: Saturday, May 22, 2010 2:13 PM
> To: r-help at r-project.org
> Subject: [R] calling Perl script from R on Windows 7
> 
> Hi list,
> I would like to capture the console output of a Perl script by running
> the
> script from R.
> I have tried the following:
> 
> # Create perl script
> cat( 'print "Hello World\n";',file="hello.pl" )
> 
> # Trial 1
> system(command="c:\\Perl64\\bin\\perl hello.pl")
> 
> -I saw no output for the above command. I have used this method before
> to
> run perl scripts that performed tasks, but only now do I want to
> capture the
> perl output from the print command within the perl script
> 
> # Trial 2
> system(command=paste(Sys.getenv("COMSPEC"),"/c","C:\\Perl64\\bin\\perl
> hello.pl"))
> - In the help for 'system' in R, it mentions making the above changes
> if one
> wants to pass a command to the cmd on a windows machine.
> 
> 
> I am using R 2.9.2 on Windows 7.
> 
> I'm doing this since I want to run perl scripts to find distance
> measures
> between words (Wordnet Similarity perl modules) and capture the numeric
> result from the perl script execution back into R. I have heard of
> RSPerl
> but I would greatly appreciate a solution using system. Writing the
> result
> to a file and then reading the file could be a another option, but I'd
> like
> to learn about capturing console output from perl into R.
> 
> 
> Any suggestions or hints would be appreciated with much gratitude.
> 
> Thanks
> Harsh
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list