[英]error while running a R script in a bash script
e made a bash script as follows: e制作了一个bash脚本,如下所示:
#! /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"
when I run the script using the following command: 当我使用以下命令运行脚本时:
bash first.sh 30 beh
I will get this error: 我会收到此错误:
mkdir: cannot create directory ‘OUTDIR’: File exists
first.sh: line 17: ./DATA/share/pipelines/script.R: No such file or directory
first step is done
do you know how to solve the problem? 你知道如何解决这个问题吗?
When you call 你打电话时
bash first.sh 30 beh
$1
holds 30
, $2
holds beh
and $3
is not defined. $1
持有30
, $2
持有beh
而$3
未定义。
input_bam
ist set to $2
but is never used. input_bam
ist设置为$2
但从未使用过。
With [ ! -d ${OUTDIR} ]
用[ ! -d ${OUTDIR} ]
[ ! -d ${OUTDIR} ]
you should be able to test if the directory exists. [ ! -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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.