Suppose I'm running a Rscript from inside this shell script
#!/bin/bash
RES=$(./abc.R 100)
r_status=echo $?
There is some code in abc.R which stops its execution
#!/usr/bin/env Rscript
...
...
if(nrow(status) == 0)
{ stop("The list id is not present in requests table. Please check.") } else if (status != 'COMPLETED')
{ stop("The list is not in COMPLETED state. Please check.")}
...
...
I am not able to capture the exit status of abc.R in my shell script. It stops R execution and even quits from the shell script to the prompt.
Is there any way I can capture R's exit status.
Just run the script you want. make sure it returns the correct exit status when finishing its run. This should work:
see more here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_08_02.html