繁体   English   中英

使用`at'执行bash脚本

[英]using `at' to execute bash script

我制作了一个bash脚本,该脚本调用jvm来执行jar编。 该脚本运行良好。 我想使用prog`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 因此,我的脚本或命令用法中肯定有问题。 我该怎么办?

无法创建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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM