Вы можете защитить попытку mv
, убедившись, что исходный файл существует, прежде чем пытаться переименовать его:
test -f /prod/new/outputlog/error.log &&
mv /prod/new/outputlog/error.log /prod/hist/new/outputlog/error.log.32423423424
Или вы можете перехватить сообщение об ошибке и попытаться разделить его на две строки:
mv /prod/new/outputlog/error.log /prod/hist/new/outputlog/error.log.32423423424 2>&1 |
fmt -s -w80 >&2
Лучше использовать файл учетных данных
-o credentials=filename|cred=filename
specifies a file that contains a username and/or password and optionally the name of the workgroup.
The format of the file is:
username=value
password=value
domain=value