I want find servers that not using "net" command. So, I'll run a script from remote. The script is like that:
for ip in $(cat ip_list_file)
do
netCom=$(ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o PasswordAuthentication=no $ip "net ads info | grep -i command | wc -l")
if [ $netCom -eq 1 ]
then
echo -e $ip >> not_installed
else
echo -e $ip >> installed
fi
done
But I have a problem at "net ads info | grep -i command | wc -l" command, because I was thinking I can use "bash: net: command not found..." sentence but I can't. I don't want reverse my script like find installed. My question is this: How can I use grep command for the outputs like "bash: net: command not found..."?
127
(see this) or to usetype
(bash builtin), e.g.type -P net
.