2012-04-05 148 views
2

我制作了一个脚本,使用名为Diascope的程序,它是一个视频幻灯片程序。bash脚本从rc.local运行

我试图在encodeVideo.sh

echo "Running diascope -clean /mnt/videos/video$1.txt..." 
diascope -clean /mnt/videos/video$1.txt > /var/www/html/video/encodeVideo.log 
echo "Removing old deploy dir, and making new one..." 

运行这个命令并使其运行我每次启动实例时,我正在从rc.local的这个脚本。

所有我需要的是让 “diascope” 命令的输出,在rc.local中我跑encodeVideo:

/bin/bash /var/www/html/video/encodeVideo.sh > /var/www/html/video/newlog 

和newlog我可以看到这个

Running diascope -clean /mnt/videos/video7.txt... 
Removing old deploy dir, and making new one... 

和/var/www/html/video/encodeVideo.log完全是空的! Diascope使用gawk,顺便说一下,当我手动运行encodeVideo.sh脚本时,我可以看到处理的输出。为什么我不能在这个日志中捕获它?

它可能不是标准输出,所以“>”实际上并没有捕获它?

任何想法会有帮助,谢谢!

回答

2

尝试重定向标准错误标准输出为filename

diascope -clean /mnt/videos/video$1.txt 1> /var/www/html/video/encodeVideo.log 2>&1 
+0

不错,谢谢 – 2012-04-05 02:22:40

+0

bash有个捷径:'command&> word' – 2012-04-05 15:03:15

+0

@glennjackman所以这个命令'diascope -clean /mnt/videos/video$1.txt 1>/var/www/html/video /encodeVideo.log 2>&1'将与'diascope -clean /mnt/videos/video$1.txt&>/var/www/html/video/encodeVideo.log'(在bash中)相同? – 2012-04-05 15:09:50

2

是否有可能,这不是标准输出,所以“>”实际上并没有抓住它?

绝对:它可能是标准错误,在这种情况下,您必须使用2>而不是>