[英]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.