I want to write a short script to ssh to different servers depending on the argument I provide - if it is a number, I want the number to be a part of the server name, if it is a letter I want it connect to a certain server. So far I have this:
#!/bin/bash
if [ $1 -eq ^[1,3-5]$ ]; then
ssh -X servername1$1
elif [ $1=h ]; then
ssh -X servername2
fi
but it keeps complaining that integer expression is expected and always tries to connect to servername2, no matter whether I give it a number or a letter. I tried quotation marks around the first and the second comparison, I tried double equality sign in the second comparison - all to no avail. How can I make this work?
Aucun commentaire:
Enregistrer un commentaire