z/OS Tools & Language

Expand all | Collapse all

Rscript didn't work

  • 1.  Rscript didn't work

    Posted 01-17-2017 06:15

    Hello,

    I installed R 3.3.1 on z/OS V2.1.
    After configuration I tried to run a simple script like following.

    I create hello.R file including just following code.

    hello.R
    print("Hello World")

    I can run this script from R console.

    $ cat hello.R
    
    print("Hello World")
    
    
    $ R -e 'source("hello.R")'
    
    R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
    Copyright (C) 2016 The R Foundation for Statistical Computing
    Platform: i370-ibm-openedition (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    > source("hello.R")
    [1] "Hello World"
    >
    

    It was successfully completed but Rscript command did not work.

    $ pwd
    /u/cics004/R
    $ ls -la | grep hello.R
    -rw-rw-rw-   1 xxxxx xxxxx 24 Jan 17 04:55 hello.R
    # Rscript --version
    R scripting front-end version 3.3.1 (2016-06-21)
    
    $ Rscript ./hello.R
    Rscript execution error: EDC5129I No such file or directory. (errno2=0x0594003D)
    
    $ Rscript /u/cics004/R/hello.R
    Rscript execution error: EDC5129I No such file or directory. (errno2=0x0594003D)
    

    How can I use Rscript command?
    The following environment variables were set at the shell on which Rscript command was issued.

    _BPXK_AUTOCVT=ON
    PATH=/usr/lpp/R331/bin:/bin:/u/cics004/Shell:/u/cics004/REXX
    CURL_CA_BUNDLE=/usr/lpp/R331/etc/sslcacert.pem
    BASE=/usr/lpp/R331
    LIBPATH=/usr/lpp/R331/lib:
    TZDIR=/usr/lpp/R331/lib/R/share/zoneinfo
    

    Regards.
    Tomohiro Taguchi



  • 2.  RE: Rscript didn't work

    Posted 01-17-2017 12:24

    Hello,

    Please run Rscript again, and include --verbose in front of the name of the file, and let us know the results.

    Also, we have released a new beta version of R, which might fix this problem. We tested your Rscript example, and it worked fine.

    Regards,
    Rick Harris
    Rocket Software



  • 3.  RE: Rscript didn't work

    Posted 01-19-2017 03:38

    Thank you for your reply.

    I installed R3.3.2 and retry but failed again.

    $ Rscript --version
    R scripting front-end version 3.3.2 (2016-10-31)
    
    $ Rscript --verbose /u/cics004/R/hello.R
    running
      '/u/pdharr/Rnew/r-dist/lib/R/bin/R --slave --no-restore --file=/u/cics004/R/hello.R'
    
    Rscript execution error: EDC5129I No such file or directory. (errno2=0x0594003D)
    

    Could you please let me know how to solve this problem?

    regards.
    Tomohiro Taguchi



  • 4.  RE: Rscript didn't work

    Posted 01-23-2017 01:21

    Hello Tomohiro,

    I see you haven’t RHOME environment variable installed. It should be installed for Rscript as following (in your case):
    RHOME=/usr/lpp/R331/lib/R. I had the same error while starting Rscript without RHOME installed.

    You can write in .profile:
    export RHOME=$BASE/lib/R

    Regards,
    Alexander



  • 5.  RE: Rscript didn't work

    Posted 01-23-2017 01:52

    Thanks.

    I added RHOME environment variable in .profile.
    I got another error.

    $ Rscript --verbose hello.R
    running
      '/usr/lpp/R332/R/lib/R/bin/R --slave --no-restore --file=hello.R'
    
    Rscript execution error: EDC5130I Exec format error. (errno2=0x0594003D)
    

    I can issue R command which is shown in above messages.

    $ R --slave --no-restore --file=hello.R
    [1] "Hello World"
    

    Could you let us know the reason of Rscript error?

    regards.
    Tomohiro Taguchi



  • 6.  RE: Rscript didn't work

    Posted 01-23-2017 18:07

    Hello Tomohiro,
    When you installed R, did you run bin/fix_distribution? If you installed both r and the libraries (python-r-devel), you need to unpack one of them, run bin/fix_distribution, then unpack the other, and run bin/fix_distribution.

    Can you please run these commands:
    ls -lT /usr/lpp/R332/R/bin/R /usr/lpp/R332/R/lib/R/bin/R
    cmp /usr/lpp/R332/R/bin/R /usr/lpp/R332/R/lib/R/bin/R
    head -l 1 /usr/lpp/R332/R/bin/R
    head -l 1 /usr/lpp/R332/R/lib/R/bin/R

    Regards,
    Rick Harris
    Rocket Software



  • 7.  RE: Rscript didn't work

    Posted 01-23-2017 20:14

    Thank you for your support.

    I did run fix-distribution command.
    I installed and configured in following steps.

    First, I tried unpack download file using "/bin/cat dist.tar.gz | gunzip -c | /bin/tar xUXof - " which is shown in R_README.ZOS file of R3.3.1, but it failed.

    $ cat r-3.3.2_b0005.170107.tar.gz | gunzip -c | tar xUXof -
    
    gzip: stdin: unexpected end of file
    633 blocks
    FSUM7131 Out of space or reached the end of the archive file.
     If you want to go on, type device or file name when ready
    

    So I unpack the distributed file by 7zip on Windows PC and then uploaded tar file.

    After that I unpacked python-devel and R in following directory for each.
    /usr/lpp/R332/python-devel
    /usr/lpp/R332/R

    python-devel install

    $ gunzip python-r-devel_b0005.161122.tar.gz
    
    $ mv python-r-devel_b0005.161122.tar python-devel/
    
    $ cd /usr/lpp/R332/python-devel
    
    $ tar -xUXof python-r-devel_b0005.161122.tar
    
    $ find . -type f -filetag u -print | wc -l
         57
    $ find . -type f -print | wc -l
      17723
    
    $ ./bin/fix-distribution
    

    R install

    $ gunzip r-3.3.2_b0005.161122.tar.gz
    
    $ mv r-3.3.2_b0005.161122.tar R/
    
    $ cd /usr/lpp/R332/R
    
    $ tar -xUXof r-3.3.2_b0005.161122.tar
    
    $ find . -type f -filetag u -print | /bin/wc -l
          8
    $ find . -type f -print | /bin/wc -l
      16381
    
    $ ./bin/fix-distribution
    

    Add environment variables in .profile

    # env for python-devel
    export BD=/usr/lpp/R332/python-devel
    export PATH=$BD/bin:$PATH
    export LIBPATH=$BD/lib:$LIBPATH
    export PKG_CONFIG_PATH=$BD/lib/pkgconfig:$BD/share/pkgconfig
    export CURL_CA_BUNDLE=$BD/etc/ssl/cacert.pem
    export FFI_LIB=$BD/lib/ffi
    export X11_DIST=$BD
    export DEVEL_DIST=$BD
    
    # env for R332
    export _BPXK_AUTOCVT=ON
    export BASE=/usr/lpp/R332/R
    export PATH=$BASE/bin:$PATH
    export LIBPATH=$BASE/lib:$LIBPATH
    export PKG_CONFIG_PATH=$BASE/lib/pkgconfig:$PKG_CONFIG_PATH
    export TZDIR=$BASE/lib/R/share/zoneinfo
    export RHOME=$BASE/lib/R
    export R_DIST=$BASE
    

    And following are command results you requested.

    $ ls -lT /usr/lpp/R332/R/bin/R /usr/lpp/R332/R/lib/R/bin/R
    t ISO8859-1   T=on  -rwxrwxrwx   1 AZUMA    STC         8884 Jan 19 07:19 /usr/lpp/R332/R/bin/R
    t ISO8859-1   T=on  -rwxrwxrwx   1 AZUMA    STC         8884 Jan 19 07:19 /usr/lpp/R332/R/lib/R/bin/R
    
    $ cmp /usr/lpp/R332/R/bin/R /usr/lpp/R332/R/lib/R/bin/R
    
    $ head -l 1 /usr/lpp/R332/R/bin/R
    #!/rsusr/ported/bin/bash
    
    $ head -l 1 /usr/lpp/R332/R/lib/R/bin/R
    #!/rsusr/ported/bin/bash
    

    I concerned about “/rsusr/ported/bin/bash” in the command result .
    Is bash required for using R ?

    regards.
    Tomohiro Taguchi



  • 8.  RE: Rscript didn't work

    Posted 01-23-2017 22:36

    Hello Tomohiro,

    The R documentation says anything that is similar enough to “sh” will work.

    Can you please copy bin/fix-distribution into a new file named bin/fix-shell.
    Then replace this line in fix-shell:
    export PREFIX=pwd
    with
    export OLD_PREFIX=/rsusr/ported/bin/bash
    and replace this line:
    . $BIN_DIR/set-distribution-original-prefix
    with
    export PREFIX=/bin/sh

    Then make sure it is properly tagged. I would run:
    autotag bin/fix-shell
    And make sure it has the right permissions:
    chmod 755 bin/fix-shell
    Then run it:
    bin/fix-shell

    I believe this should fix the problem.

    Regards
    Rick Harris
    Rocket Software



  • 9.  RE: Rscript didn't work

    Posted 01-24-2017 00:32

    Hello,

    I can run Rscript normally after issuing fix-shell.

    Thank you so much !!!

    regards.
    Tomohiro Taguchi