我是Linux的新手,但是我正在为Antlr4做一个教程。最近,我遇到了一个问题。当我尝试设置Antlr4项目时,我在终端中运行以下命令:
antlr4 MyGram.g4
javac *.java
grun MyGram prog test.in
dot -Tpdf test.dot > test.pdf
一切正常,它会创建一个显示分析树的pdf文件。 但是,当我将这些命令放到一个名为build.sh的bash脚本中时:
#!/bin/bash
antlr4 MyGram.g4
javac *.java
grun MyGram prog test.in
dot -Tpdf test.dot > test.pdf
,然后运行命令: ./build.sh 并且出现以下错误,并且没有创建pdf文件:
./build.sh: line 3: antlr4: command not found
javac: file not found: *.java
Usage: javac <options> <source files>
use -help for a list of possible options
./build.sh: line 5: grun: command not found
Error: dot: can't open test.dot
谁能解释我得到这些错误的原因?我正在VMware Workstation 14 Player上运行Ubuntu 18.04。
答案 0 :(得分:1)
由于某些原因,antlr4和grun不在$ PATH中。
type antlr4
将向您显示它的位置。将其添加到.bashrc或.profile中的PATH
答案 1 :(得分:1)
df['Reopened'] = ((df == 'Open') & ((df.shift(axis=1)) == 'Closed')).any(axis=1).astype(int)
print (df)
T1 T2 T3 T4 T5 Reopened
1 Open In Progress Closed NaN NaN 0
2 In Progress Closed NaN NaN NaN 0
3 Open In Progress Open Closed NaN 0
4 Open In Progress Closed Open Closed 1
5 Open In Progress Closed NaN NaN 0
和antlr4
是您在命令窗口中定义的别名。
运行脚本时,您所处的环境不同。
所以您应该:
我同意@Tejas的评论:您应该在脚本中使用完整路径(更容易维护)