Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Execute R script from a 'shell script' step

  1. #1
    Join Date
    Mar 2011
    Posts
    7

    Default Execute R script from a 'shell script' step

    I am trying to execute an R script from a kettle job, and I don't really know whether it's a kettle or an R problem I am facing.

    I use the shell script step, where I call an R script that begins with the #!/usr/bin/Rscript. I works fine, the only problem is that the argument passed to the R script is not transferred as intended. The argument is a directory path that I would like to set as a working directory for the r script.

    Here is what the R script looks like:
    Code:
    #!/usr/bin/Rscript 
    args <- commandArgs(TRUE)
    setwd(args)
    When I run this from a shell, like
    Code:
    ./some_script.R /some/path/
    it works fine. But when I start this from the shell script step, it fails with the message: can not change working directory. I am sure that the argument is ok, when I copy/paste the command from the log to a shell, it runs smoothly.

    Any help is appreciated, thanks.
    Last edited by torzsok; 01-22-2015 at 03:32 PM.

  2. #2
    Join Date
    Mar 2011
    Posts
    7

    Default

    Is there any hope someone can help solving this?

  3. #3
    Join Date
    Sep 2015
    Posts
    9

    Default

    Hi Torzsok,
    I am also trying to run a R script using Shell in the pentaho job step.
    The R script runs fine when I run it in R. It simply reads and writes a text file.
    So far I did not encounter yet a good explanation on how to do this.

    This is what I tried:
    In the Shell step -> Script file name C:\.R test\PentahoShell.r (pointing to the directory where the R script is located).
    -> Working directory C:\.R test\ (the working directory of R).
    In the R script i put in as first line #!/usr/bin/Rscript

    When running the pentaho job, Windows asked me to select the program to use for opening the R file.
    -> I selected the .exe file that is normally used for starting up R -> C:\Program Files\R\R-3.2.2\bin\i386\Rgui.exe
    -> Pentaho throws in an error " ARGUMENT 'C:\.R test\PentahoShell.r' __ignored__".

    So no luck for me yet, to run the R script from Pentaho using Shell.
    I am using Pentaho 5.4

  4. #4
    Join Date
    Sep 2015
    Posts
    9

    Default

    It worked running the script by making the R file executable =) Saving it as .Rexec extension, and allowing Windows to run it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.