Hi:
I use the snmpget command everyday. And Im getting tire of writing the same line evertime I have to verify something.
Example of the line:
snmpget -c DreamTeam dal2-hr2 ifAlias.227
The .227 its the circuit interface and also its variable; could be any other number depending on the circuit id. So I create an alias in which it works:
alias sn='snmpget -c DreamTeam dal2-hr2'
So, now all I have to do its to write "sn ifAlias.227" and works fine; but!
if I create a new alias like:
alias sn='snmpget -c DreamTeam dal2-hr2 ifAlias." makes me an error;
so when I write "sn 227" it fails. Also if I did the alias without the "." and run the "sn .227" also fails.
How can I add the .227 to that ifAlias string. Or how to create a variable so
the "ifAlias.xxx" so makes the command works?!!
Wow!.. Interesting. I left at work but I will try tomorrow!. Thanks a lot.
By the way, you said about a shell script. Let me explain something to see if I can make a better program than the aliases I created.
I have created an executable file named "snmp.env". Inside the file I have the following:
alias dal1='snmpget -c DreamTeam dal2-hr1'
alias dal2='snmpget -c DreamTeam dal2-hr2'
alias lon1='snmpget -c DreamTeam lon1-hr1'
alias lon2='snmpget -c DreamTeam lon2-hr2'
And so on... Its like 12 aliases like that. So when I ran it I just do:
dal1 ifAlias.236 [ENTER], and so on. So as you explained me and I told you the .236 its a variable; it could be any number.
I understood of creating the 'sn' file and inside it to add in the file:
snmpget -c DreamTeam ifAlias.$1 so all I have to do to run its
its just "sn 236" and thats great!...
Now about the shell function; How can I add all other aliases to the shell function? Or do I have to create each shell function individually instead of creating a nice shell function with all aliases I want?
Thanks for everything. I was able to create every single file for each snmp I have to run. Twelve files; but works great! All I have to do now its doing the "dal1 227" and done!...
What I was trying to do the same thing but in a shell function; but couldnt.
No idea how to do it. I create a file for test named "sn.sh" and inside the file
I wrote the following code:
sn()
{
snmpget -c DreamTeam dal2-hr1 ifAlias.$1
}
But I have no idea how to call it and run it or if there's something wrong or missing. Can anyone help? Thanks!!
I got it. Thanks. I did the function and for some reason when I ran it it doesnt like it. It says "Too Many Arguments".... But when I did the script named "sn" and inside the file I wrote "snmpget -c DreamTeam ifAlias.$1". All I have to do to run its is "sn 227" and works.