【发布时间】:2020-08-06 17:43:29
【问题描述】:
到目前为止的脚本(不工作):
#!/bin/bash
while read line
uname="cat /etc/passwd | grep bash | sed 's/:.*//'"
echo "config system admin
for each line $uname >
if $uname = "root" then
echo "skipping $uname 'root'" else
echo "edit '$uname'/n
set remote-auth enable/n
set trusthost1 8.8.8.8 255.255.255.255/n
set accprofile "admin"/n
set vdom "root"/n
set remote-group "foobar"/n
set password ENC potatoes/n
next/n" > output.txt
“cat /etc/passwd | grep bash | sed 's/:.*//'”的输出
foo
root
bar
“output.txt”中的预期输出,“/etc/password”中列出的三个用户是 foo、root 和 bar:
config system admin
edit foo
set remote-auth enable
set trusthost1 8.8.8.8 255.255.255.255
set accprofile "admin"
set vdom "root"
set remote-group "foobar"
set password ENC potatoes
next
edit bar
set remote-auth enable
set trusthost1 8.8.8.8 255.255.255.255
set accprofile "admin"
set vdom "root"
set remote-group "foobar"
set password ENC potatoes
next
【问题讨论】:
标签: linux bash ubuntu ubuntu-16.04