Bash 中的 if 语句问题

Bash 中的 if 语句问题

第一次在这里互动。它帮了我好几次忙,但这次我迷路了。我从@bulljit那里得到了一个删除停滞/结束的种子的脚本。(我不知道我是否可以/应该把他的 Github 放在这里。如果我错了,请见谅)。原始代码在这里: https://gist.github.com/bulljit/791609/3d3e3f9ed7d3d9ad140c2bade503b5864bd475bb

但我决定更进一步,为种子设置一个 RATIO 值,因为我的网络连接不是很好。以下是我想到的:(我所做的更改在 {} 内,因为代码中没有任何内容。)

#!/bin/sh
# the folder to move completed downloads to port, username,
# password
SERVER="192.168.1.105:9091"

# use transmission-remote to get torrent list from
# transmission-remote list use sed to delete first / last line
# of output, and remove leading spaces use cut to get first
# field from each line
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=" " --fields=1`
transmission-remote $SERVER --list

# for each torrent in the list
for TORRENTID in $TORRENTLIST
do
echo Processing : $TORRENTID

# check if torrent download is completed
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`

# check torrents current state is
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
echo $STATE_STOPPED
{
**#check if the selected Ratio was completed
RATIO=`echo "$INFO" | grep "Ratio: 0.5"`**
}
# if the torrent is "Stopped", "Finished", or "Idle" after
# downloading 100%"
if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ] {&& [ "$RATIO" != "0.5" ]}; then

echo "$SERVER and $TORRENTID and TORRENTLIST"

# move the files and remove the torrent from Transmission
echo "Torrent #$TORRENTID is completed"
echo "Removing torrent from list"
transmission-remote $SERVER --torrent $TORRENTID --remove
else
echo "Torrent #$TORRENTID is not completed. Ignoring."
fi
done

问题是我下载的量并没有大家想象的那么多,但我想尝试一下并使用这些功能。但所有种子都被删除了,不仅仅是那些已经完成播种的种子。如果我在错误的论坛,请原谅...

相关内容