
#!/bin/bash
while read P
do
ssh "$P" /usr/lib/update-notifier/apt-check -p &&
sudo apt-get upgrade --dry-run
done < ~/iplist1
結果必須如下所示:
Server1 name
possible updates
Server2 name
possible updates
答案1
這個怎麼樣?
#!/bin/bash
while IFS='' read -r p || [ -n "$p" ]; do
ssh "$p" bash -c '\
hostname &&
[[ -z "$(/usr/lib/update-notifier/apt-check -p)" ]] &&
echo "No updates available." ||
( echo ; apt-get upgrade --dry-run )
'
echo
done < ~/iplist1
apt-get --dry-run
不需要root權限來運行,這消除了一個主要問題。