Skip to content
Advertisement

How can i give specific commands to programs via terminal Linux?

I’m seeking for a way to automatize the configuration of some tasks i do, but, i am having some trouble to give the order to the programs from the terminal.

I have actually to give, every time i try to configure some Routers, the same commands always and always, but, i’m looking for a way to create a Shell Script to do it for me. The problem, is. I must access a server with terminal to do that,so i can’t give the commands as i always do, with terminal. I need a way to insert the commands inside the terminal.

This is the terminal i’m wanting to automatize enter image description here

As you can see, i ways have to do the same commands, that would be pretty better, if the Shell Script, itself, did it for me.

Last but no least, there is a sample of what i tried to do:

#!/usr/bin/env bash
telnet 192.168.255.2 & < enable; show port epon 1/1 registered-link;
show port epon 1/2 registered-link; show port epon 1/3 registered-link;
show port epon 1/4 registered-link; show port epon 2/1 registered-link; 
show port epon 2/2 registered-link; show port epon 2/3 registered-link; 
show port epon 2/4 registered-link; show port epon 3/1 registered-link; 
show port epon 3/2 registered-link; show port epon 3/3 registered-link;
show port epon 3/4 registered-link; show port epon 4/1 registered-link;
show port epon 4/2 registered-link; show port epon 4/3 registered-link;
show port epon 4/4 registered-link; 

“telnet 192.168.255.2” is the server and the oders, are the commands it must do.

Anyway, thank you very much.

Advertisement

Answer

Fabric is your friend, designed exactly for that kind of task. http://www.fabfile.org/

You may use Fabric3 if you prefer Python 3. https://pypi.python.org/pypi/Fabric3

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement