首页 > 解决方案 > 可以在终端中执行命令,但不能从文本文件中执行

问题描述

我在 WSL 上使用 Ubuntu 运行代码。每次我编辑一些 C 文件时,我都需要执行一个 makefile 并运行一个安装程序,以确保这些更改反映在我正在使用的 python 包中。我需要执行的命令集是

make clean
make 
cd python
python setup.py install --user

当我在终端中执行它们时,这非常有效。为了让我的生活更轻松,我决定将这些命令放在一个文本文件Compile.txt中,以便在需要编译相关文件时执行。我发现了这个问题并试图复制它的解决方案。但是,每当我输入./Compile.txt终端时,我都会收到错误

'.  Stop. No rule to make target 'clean
gcc      -o .o
gcc: fatal error: no input files
compilation terminated.
make: *** [<builtin>: .o] Error 1
./Compile.txt: line 7: cd: $'python\r': No such file or directory
python: can't open file 'setup.py': [Errno 2] No such file or directory

谁能解释我做错了什么?对于任何滥用术语的行为,我深表歉意,因为我对 Linux 还是很陌生。

提前致谢。

标签: linuxbashshellmakefilewindows-subsystem-for-linux

解决方案


推荐阅读