我编写了一个bash脚本,调用jvm来执行jar程序。脚本运行良好。我想在某个时候使用程序' at'来执行我的bash脚本,但是该脚本只能部分地工作:
#!/bin/bash
touch hello.world
while read line
do
touch another.hello.world
name=$line
...
done < "/users/me/readin.txt"
我使用的命令:
$ at -f myscript.bash now
你好。生成了世界文件,但没有另一个。hello. World 。所以,一定是我的脚本或命令用法有问题。我该怎么办?
不创建another.hello.world
文件的唯一可能性是while循环的迭代至少没有发生一次。
所以可能输入文件/users/me/readin.txt
是空白的。
我建议你用set -x
选项执行代码,你会发现原因。它将显示正在执行的跟踪。
#!/bin/bash
touch hello.world
set -x
while read line
do
touch another.hello.world
name=$line
...
done < "/users/me/readin.txt"
set +x