You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1016B

  1. #!/bin/bash
  2. # Wrapper to easily run an R script at the command line, with arguments,
  3. # like you're used to with Python/Perl/Ruby/Bash/anything else remotely sane.
  4. #
  5. # Usage:
  6. # $(echo $0) -p <program_name> <args>
  7. set -eu -o pipefail
  8. export LC_ALL=en_US.UTF-8
  9. # Find original directory of bash script, resolving symlinks
  10. # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in/246128#246128
  11. SOURCE="${BASH_SOURCE[0]}"
  12. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  13. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  14. SOURCE="$(readlink "$SOURCE")"
  15. [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  16. done
  17. BINDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  18. echo "Binary directory: ${BINDIR}"
  19. if [ -f "$BINDIR/cn.mops.R" ];then
  20. Rscript "$BINDIR/cn.mops.R" "$@"
  21. else
  22. echo "No such r script: $BINDIR/cn.mops.R"
  23. fi