在bash脚本中运行R脚本时出错

时间:2019-06-11 13:33:27

标签: r bash

e制作了一个bash脚本,如下所示:

PickListEntry.ReceiptEntryFK

当我使用以下命令运行脚本时:

#! /bin/bash


OUTDIR=".//DATA/share/pipelines/results/"
INDIR="./DATA/share/pipelines/test_data/infile/"
projectname=$1
input_bam=$2
bins=$3

mkdir OUTDIR || true

of="${OUTDIR}"
ind="${INDIR}"


./DATA/share/pipelines/script.R \
    -b "${bins}" \
    -c "${projectname}" \
    -o "${of}" \
    -i "${ind}"

echo "first step is done"

我会收到此错误:

bash first.sh 30 beh

你知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

致电时

bash first.sh 30 beh

$1持有30$2持有beh,而$3未定义。

input_bam设置为$2,但从未使用过。

使用[ ! -d ${OUTDIR} ],您应该能够测试目录是否存在。

#! /bin/bash

#Please check if it should be
# relative to the current working directory (starting with './')
# or absolute (starting with '/')
BASEDIR="/DATA/share/pipelines/" #"./DATA/share/pipelines/"
OUTDIR=${BASEDIR}"results/"
INDIR=${BASEDIR}"test_data/infile/"
projectname=$1
input_bam=$2  #This is never used
bins=$3  #This is not defined when callin >bash first.sh 30 beh<

[ ! -d ${OUTDIR} ] && mkdir ${OUTDIR} #Think you would create ${OUTDIR}

of="${OUTDIR}"
ind="${INDIR}"


./DATA/share/pipelines/script.R \
    -b "${bins}" \
    -c "${projectname}" \
    -o "${of}" \
    -i "${ind}"

echo "first step is done"
相关问题