Monday, August 8, 2011

The "do" Command

Don't you just hate it when your in the middle of implementing a new configuration but then decide you'd like to issue a show or ping command so you drop down to privileged EXEC mode? For example: 

R2(config)#router eigrp 10
R2(config-router)# network 192.168.20.2 0.0.0.0

R2(config-router)#exit
R2(config)#exit
R2#
R2#ping 192.168.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/52/92 ms

You could always use "Control" + "Z", however, you still lose your current "spot" in your configuration hierarchy. In the example above, in order to get back to your original configuration mode, you'd need to issue the following commands: 

R2#conf t
R2(config)#router eigrp 10

By using the "do" command you no longer have to leave your current configuration level. 

If you need to do this several times, for example, to test ping connectivity, it can be quite time consuming.  To save time you could employ the use of the "do ping" command, as per the example below: 

R2(config)#router eigrp 10

R2(config-router)# network 192.168.20.2 0.0.0.0
R2(config-router)#do ping 192.168.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/55/132 ms


Another example would be the "do show run" command to verify that you have the correct configuration on an interface: 

R2(config-router)#do sh run int fa0/0
Building configuration...

Current configuration : 99 bytes
!
interface FastEthernet0/0
 ip address 192.168.20.2 255.255.255.252
 duplex auto
 speed auto
end


The only downfall of the "do" command is that it does not let you use the "?" or "TAB" button to assist you in completing/finding a command. For example: 

R2(config-router)#do ping ?
% Unrecognized command
R2(config-router)#do ping 192.168.20.1 source fa0/0 ?
% Unrecognized command
R2(config-router)#do ping 192.168.20.1 source fa0/0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.20.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/44/64 ms


As per the above, it says valid commands are invalid. However, if you know that they are correct, you can issue them anyway and the device will give you the correct output. The reason why this is a downfall is because if you cannot remember the command's syntax, you'll need to drop down to the privileged EXEC mode.

As always, if you have any questions or have a topic that you would like me to discuss, please feel free to post a comment at the bottom of this blog entry, e-mail at myciscolabsblog@gmail.com, or drop me a message on Twitter (@OzNetNerd).

Note: This website is my personal blog. The opinions expressed in this blog are my own and not those of my employer.

No comments:

Post a Comment