linux中没有这样的文件或目录错误

时间:2013-08-20 11:47:07

标签: linux directory

最近我安装了一个名为“paradigm”的程序。在程序路径(/ home / hora / Paradigm /)中有一个目录“testdata”(/ home / hora / Paradigm / testdata),其中包含一个运行应用程序示例测试的shell脚本。我第一次安装了程序我能够运行shell脚本(runtests.sh)但现在我尝试运行它我得到“没有这样的文件或目录”的错误,虽然错误提到的文件在那里。我确信问题是由于我对linux缺乏了解,我们将非常感谢您的帮助。为了说明这种情况:

hora@serv:~/Paradigm/testdata$ ./runtests.sh 
Testing node splitting [1/2], should take seconds
diff: needs_split_1.out: No such file or directory
./runtests.sh: line 6: ../pathwaytab2daifg: No such file or directory

但如果我列出目录内容,那么上述文件就在那里:

hora@serv:~/Paradigm/testdata$ ls 
complex_family_pathway.tab      needs_split_1.cfg          needs_split_2.out          runtests.sh                    small_disconnected_pathway.tab
complex_family_pathway.tab.out  needs_split_1.out          needs_split_2.pathway.tab

然后:

 hora@serv:~/Paradigm$ ls 
 common.h           configuration.o    
 evidencesource.o  helperScripts  makefile         
 pathwaytab2daifg.cpp  pathwaytab.h      test1 configuration.cpp 
 evidencesource.cpp  externVars.cpp    main.cpp       paradigm         
 pathwaytab2daifg.o    pathwaytab.o      testdata configuration.h   
 evidencesource.h    externVars.o      main.o         pathwaytab2daifg 
 pathwaytab.cpp        README.mediawiki

这是脚本内容(有问题的部分):

#!/bin/bash

set -o pipefail
cd 
echo Testing node splitting [1/2], should take seconds
../pathwaytab2daifg needs_split_1.pathway.tab needs_split_1.cfg  \
    | diff needs_split_1.out - || exit 1

2 个答案:

答案 0 :(得分:4)

我相信此脚本的作者希望您将HOME设置为~/Paradigm,或者他们希望您直接安装在您的HOME目录(~)而不是{{1} }}。无论哪种方式,这都是他们的错误。一个简单的修复可能是将安装移至~/Paradigm,或尝试:

~

(请注意,除非您正在运行env HOME=$(pwd) ./runtests.sh家庭shell,例如envcsh,否则无需csh。设置tcsh会在没有参数的情况下更改HOME的行为,并使HOME的值成为目标目录。

答案 1 :(得分:3)

这一行:

#!/bin/bash

set -o pipefail

cd #<----- here!

echo Testing node splitting [1/2], should take seconds
../pathwaytab2daifg needs_split_1.pathway.tab needs_split_1.cfg  \
    | diff needs_split_1.out - || exit 1

正在将目录更改为~/,如果您未向其传递路径,则cd的默认参数为cd(请参阅here)。

如果您愿意,可以通过向cd提供绝对路径,即将cd /home/hora/Paradigm/testdata行更改为{{1}}来修复脚本在任何地方工作。