Предлагаю следующие изменения и исправления:
#!/bin/bash
#first we test whether we have enough input parameters
if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then
echo "usage: $0 <user_name> <compression method bz2|gz|Z>"
fi
#test if we have read access to the users home directory
if [ ! -r /home/$1 ]; then
echo "could not read /home/${1}"
exit 1
fi
#now we parse the compression method and set the correct tar flag for it
case $2 in
"bz2")
flag=j;;
"gz")
flag=z;;
"Z")
flag=Z;;
*)
echo "unsupported compression method valid methods are <bz2|gz|Z>"
exit 1;;
esac
#we need to enclose variable names not followed by whitespace in {} otherwise the letters following the variable name will be recognized as part of the variable name
tar -${flag}cvf /var/tmp/${1}_$(date +%Y%m%d).tar.$2 /home/${1}/
chmod 777 /var/tmp/${1}_$(date +%Y%m%d).tar.$2
echo "Nightly Backup Successful: $(date)" #>> /var/tmp/backup.log
скрипт вызывается так:
backup.sh user bz2
если вы хотите, чтобы имя пользователя и метод сжатия вводились интерактивно, используйте ваш код, который это делает, и замените ${1} на ${UserName} (и $1 на $USerName) и ${2} на ${CompressionMethod}
удачи в домашней работе.
Хорошо, я решил свои проблемы, вот решение :https://forums.opensuse.org/showthread.php/531935-Most-internet-connectabilities-not-workningПросто используйте это обновление :netconfig -f На кли