Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix tcshell脚本中的澄清_Unix_Tcsh - Fatal编程技术网

Unix tcshell脚本中的澄清

Unix tcshell脚本中的澄清,unix,tcsh,Unix,Tcsh,我在tcshell中有一个脚本,由于某些原因它不能工作 有人能用同样的方式指出这个问题吗 #!/usr/bin/tcsh while true do if ls /sample/test3 >& /dev/null ; then /sample/app_code/run/initiateLoad.sh ; endif sleep 1800 done 路径/sample/test3包含文件,因此if条件应该已经成功,并且应该已经启动shell脚本,但是它没有发生。

我在tcshell中有一个脚本,由于某些原因它不能工作

有人能用同样的方式指出这个问题吗

#!/usr/bin/tcsh
while true
do
    if ls /sample/test3 >& /dev/null  ; then /sample/app_code/run/initiateLoad.sh ; endif
    sleep 1800
done

路径/sample/test3包含文件,因此if条件应该已经成功,并且应该已经启动shell脚本,但是它没有发生。

您正在测试
ls
的退出代码,而不是
/sample/test3
中是否有文件。测试
ls
的退出代码是合适的,如果没有匹配的文件,它将返回1,但是[t]csh不会像ksh/bash/sh那样计算嵌入的cmd。可能
if(`ls/s/test3`>&/dev/null);然后将起作用。否则,请在csh中找到测试的正确形式。(我所有的csh代码都在一张3 1/2英寸的软盘上,通常有用的`并没有帮助我们获得所需的建议。)当然,建议是“停止使用[t]csh编写脚本!,但有时说起来容易做起来难。祝你好运。