添加日志文件命令会将脚本置于循环中吗?

时间:2019-03-28 12:49:56

标签: linux bash shell centos

我正在尝试为脚本的输出/终端文件创建日志文件。 为什么脚本会循环?

脚本用于使用带有地址列表的导入的.txt文件通过ssh远程更改密码。脚本运行良好,直到我在完成后在末尾添加用于记录的行:

#!/bin/bash

echo "Enter the username for which you want to change the password"

read USER

sleep 2

echo "Enter the password that you would like to set for $USER"

read PASSWORD

sleep 2

echo "Enter the file name that contains a list of servers. Ex: ip.txt"

read FILE

sleep 2

for HOST in $(cat $FILE)

do 

ssh root@$HOST  "echo $'$PASSWORD\n$PASSWORD' | passwd $USER"

done

我尝试添加以下日志创建命令:

/root/passwordchange.sh | tee -a /root/output.log

logsave -a /root/output.log /root/passwordchange.sh

/root/passwordchange.sh >> /root/output.log

添加日志记录行将为整个程序创建循环,而不是将其关闭。 我需要使用sigkill脚本来结束该过程。

将使用所有提供的信息照常创建输出文件。

这是我的第一个问题,在此先谢谢您的回答

0 个答案:

没有答案