【发布时间】:2014-08-21 15:24:05
【问题描述】:
我不记得在哪里找到的,但我有一个脚本,一旦种子完成播种,就会从传输中删除种子。
我想添加一个部分来删除损坏的种子。损坏的种子将具有以下行:
错误:未找到数据!确保您的驱动器已连接或使用“设置位置”。要重新下载,请移除种子文件并重新添加。
这是我的脚本:
#!/bin/sh
#transmission-remote --auth=user:pass --torrent 1 --info
#transmission-remote --auth=user:pass --list
TRUSER='user'
TRPASS='pass'
TORRENTLIST=`transmission-remote --auth=$TRUSER:$TRPASS --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=' ' --fields=1`
for TORRENTID in $TORRENTLIST
do
echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *"
DL_COMPLETED=`transmission-remote --auth=$TRUSER:$TRPASS --torrent $TORRENTID --info | grep "State: Finished"`
if [ "$DL_COMPLETED" != "" ]; then
echo "Torrent #$TORRENTID is completed."
echo "Removing torrent from list."
transmission-remote --auth=$TRUSER:$TRPASS --torrent $TORRENTID --remove-and-delete
else
echo "Torrent #$TORRENTID is not completed. Ignoring."
fi
echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *"
done
for TORRENTID in $TORRENTLIST
do
echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *"
DL_STOPPED='transmission-remote --auth=$TRUSER:$TRPASS --torrent $TORRENTID --info | grep -o "Error: No data found"'
if [ "$DL_STOPPED" = !"" ]; then
echo "Torrent #$TORRENTID is corrupted."
echo "Removing torrent from list."
transmission-remote --auth=$TRUSER:$TRPASS --torrent $TORRENTID --remove-and-delete
else
echo "Torrent #$TORRENTID is not corrupted. Ignoring."
fi
echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *"
done
我认为在 grep 之后添加“-o”可以解决我的问题,但是这会删除所有未损坏的种子。
如何让此脚本删除已完成的播种和损坏的种子?
这是我第一次发帖,所以我希望我做得对。
艾迪
【问题讨论】: