简体   繁体   English

Bash脚本:没有这样的文件或目录

[英]Bash script: No such file or directory

So, i need to run this run.sh file and i could not with windows default CMD . 所以,我需要运行这个run.sh文件,我无法使用Windows默认CMD So i installed Cygwin64 Terminal and it acctualy reads the file, but at the end of the reading, it spams an error: 所以我安装了Cygwin64终端并且它确实读取了文件,但是在读取结束时,它发送了一个错误:

$ /cygdrive/c/Python27/Scripts/./run.sh
Starting scraper
Scrape complete, checking movies with imdb
C:\python27\python.exe: can't open file 'check_imdb.py': [Errno 2] No such file or directory

Inside run.sh : run.sh内

#!/bin/bash
echo "Starting scraper"
scrapy runspider cinema_scraper.py -t json --nolog -o - > "movies.json"
echo "Scrape complete, checking movies with imdb"
python check_imdb.py movies.json

check_imdb.py is inside run.sh folder. check_imdb.py在run.sh文件夹中。

The file is referenced inside the script as a relative path. 该文件在脚本内作为相对路径引用。

python check_imdb.py movies.json

Relative means that it does not specify the whole path (starting with /), and is interpreted relative to the current directory, which you can find out with : 相对意味着它不指定整个路径(以/开头),并且相对于当前目录进行解释,您可以通过以下方式找到:

pwd

A path starting with / is said to be absolute. /开头的路径被认为是绝对的。

The important thing is to remember a script interprets paths relative to the current directory, not the directory where the script is located. 重要的是要记住脚本解释相对于当前目录的路径,而不是脚本所在的目录。

You could change to the directory of the script before running it, with : 您可以在运行前更改脚本目录,其中包括:

cd /cygdrive/c/Python27/Scripts

But if you do that, then you will need to provide an absolute path on the command line to your movies.json file. 但是如果你这样做,那么你需要在movies.json文件的命令行上提供一个绝对路径。

Better yet, modify the script to have an absolute path: 更好的是,修改脚本以获得绝对路径:

python /cygdrive/c/Python27/Scripts/check_imdb.py movies.json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在新文件目录下运行bash脚本? - Run a bash script when new file directory? 从 cronjob 运行 bash 脚本失败并显示“没有这样的文件或目录” - Running a bash script from a cronjob fails with “No such file or directory” bash:./run:没有这样的文件或目录 - bash: ./run: No such file or directory pythonanywhere bash 没有这样的文件或目录? - pythonanywhere bash No such file or directory? 使用BASH脚本更改目录不起作用 - changing directory with BASH script not working Django 1.9:将变量从python脚本传递到bash脚本-OSError:[Errno 2]没有这样的文件或目录 - Django 1.9 : Pass variables from python script to bash script - OSError : [Errno 2] No such file or directory 无法打开文件'demo.py':[Errno 2] 通过 bash 脚本运行时没有这样的文件或目录 - Can't open file 'demo.py': [Errno 2] No such file or directory when running through a bash script -bash:cd:资源:没有这样的文件或目录 - -bash: cd: Resources: No such file or directory Bash 脚本,用于识别子目录中的文件扩展名并相应地对父目录进行分组 - Bash script to identify file extension in a sub directory and group the parent directors accordingly Py2 - 使用 Arguments 运行 Bash 脚本 - 将 Output 存储在不同目录中的文件中 - Py2 - Run Bash Script with Arguments - Store Output in a file in a different directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM