I am not sure what I am doing wrong, it just doesn't make sense the reason its not working:
This one I do get the SSH result as expected
if [ "Hennopsview" != "2 - LAN" ] && [ "Hennopsview" != "1 - WAN" ] && [ "Hennopsview" != "Cross Connect" ]; then if [[ "Hennopsview" =~ /pptp/g ]]; then echo "No Match 2"; else ssh admin@192.168.0.1 ':put [/interface eoip get [/interface eoip find name="Hennopsview"] remote-address]'; fi else echo "No Match"; fi
The following one however doesn't give me the Match 2 echo
if [ "<pptp-hennopsview>" != "2 - LAN" ] && [ "<pptp-hennopsview>" != "1 - WAN" ] && [ "<pptp-hennopsview>" != "Cross Connect" ]; then if [[ "<pptp-hennopsview>" =~ /pptp/g ]]; then echo "No Match 2"; else ssh admin@192.168.0.1 ':put [/interface eoip get [/interface eoip find name="<pptp-hennopsview>"] remote-address]'; fi else echo "No Match"; fi
What is wrong with this regular expression
The following however fixes the second request
if [ "<pptp-hennopsview>" != "2 - LAN" ] && [ "<pptp-hennopsview>" != "1 - WAN" ] && [ "<pptp-hennopsview>" != "Cross Connect" ]; then if [[ "<pptp-hennopsview>" =~ [pptp] ]]; then echo "No Match 2"; else ssh admin@154.127.117.218 ':put [/interface eoip get [/interface eoip find name="<pptp-hennopsview>"] remote-address]'; fi else echo "No Match"; fi
but then breaks the original one
if [ "Hennopsview" != "2 - LAN" ] && [ "Hennopsview" != "1 - WAN" ] && [ "Hennopsview" != "SDA - Cross Connect" ]; then if [[ "Hennopsview" =~ [pptp] ]]; then echo "No Match 2"; else ssh admin@154.127.117.218 ':put [/interface eoip get [/interface eoip find name="Hennopsview"] remote-address]'; fi else echo "No Match"; fi
I do understand that using "[pptp]" is a character match and not word. By why when replacing "[" with "/" doesn't fix the issue?
Regards
Aucun commentaire:
Enregistrer un commentaire