Code: Select all
#!/bin/bash
user=admin
read -sp 'Password ' pass
log=StrictHostKeyChecking=no
locdir=/home/user/backup/
rm -rf /root/.ssh/known_hosts
d=$(date '+%d-%b-%Y')
mkdir $locdir/user_$d
cd $locdir/user_$d
while read n h;do
sshpass -p $pass ssh -o $log -n $user@$h -p 4777 '/ip dhcp-server lease;:foreach i in=[find where host-name="pc"] do={:put [get $i address]}' file=$n
sshpass -p $pass ssh -o $log -n $user@$h -p 4777 file remove $n.txt
done < $locdir/hostscg.txt
I want now to use it with mikrotik script to grep it, and this command
Code: Select all
/ip dhcp-server lease;:foreach i in=[find where host-name="pc"] do={:put [get $i address]}
Why?
Password Warning: Permanently added '[10.10.46.1]:22' (RSA) to the list of known hosts.
expected end of command (line 1 column 100)
Connected to 10.10.46.1.
File "/RemoteShop1.txt" not found.
no such item