Discussion:
[rancid] clogin with command file - special signs
alligator94
2012-10-31 15:20:57 UTC
Permalink
Dear all,



I would like to use the command "clogin -x file.txt device-name" to add a
snmp configuration in a lot of cisco devices. The community string includes
the characters !@$ and the clogin command is rejected.

I also have tried to use the -c option and to quote the commands, but I get
the same error message



ex :

clogin -x "conf t ; snmp-server community rrr!@$ooo RW my_acl; end; wr; q"
device_name



I get the message :



-su !@$ooo event not found





Is there a workaround ?



Thanks

Gilles
Chris Gauthier
2012-10-31 15:36:33 UTC
Permalink
Sent: Wednesday, October 31, 2012 8:21 AM
Subject: [rancid] clogin with command file - special signs
Dear all,
I also have tried to use the -c option and to quote the commands, but I get the same error message
Is there a workaround ?
Thanks
Gilles
I believe you can escape those characters or put them inside a single-quote to make it a more literal translation. I have given examples of both below. I think that option 1 will probably work better, but don't hold me to that.

1) clogin -x "conf t ; snmp-server community rrr\!\@\$ooo RW my_acl; end; wr; q" device_name
2) clogin -x 'conf t ; snmp-server community rrr!@$ooo RW my_acl; end; wr; q' device_name

Chris

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE
Attention: The information contained in this email and/or attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any system and destroy any copies.
Chris Gauthier
2012-10-31 15:51:29 UTC
Permalink
-----Original Message-----
Sent: Wednesday, October 31, 2012 8:48 AM
To: Chris Gauthier
Subject: Re: [rancid] clogin with command file - special signs
Post by Chris Gauthier
end; wr; q" device_name
I did not even consider that the first time. Escaping special characters is not one of my strong points in the shell. I'm constantly having to tweak my grep strings for that very reason. Also, please post to the list next time so everyone can benefit from the knowledge. I know when you hit "Reply" that is not the default behavior, but the knowledge transfer is very useful.

Chris

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE
Attention: The information contained in this email and/or attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any system and destroy any copies.
Trix Farrar
2012-10-31 15:56:28 UTC
Permalink
Post by Chris Gauthier
I believe you can escape those characters or put them inside a
single-quote to make it a more literal translation. I have given
examples of both below. I think that option 1 will probably work
better, but don't hold me to that.
I haven't tested either, but I don't think either of your examples
will work. As I sent to OP, there are two levels of escaping that
need to be done. I belive the correct approach will be to combine
both of your examples by using single quotes on the command line -- to
keep the shell from catching the '@' and '$' (and backslashes) -- and
backslash escaping the special characters to keep the Tcl interprater
from seeing them before they can be passed to the device. This
yields:

3) clogin -x 'conf t ; snmp-server community rrr\!\@\$ooo RW my_acl; end; wr; q' device_name

(reposted to the list, by request)
--
John D. "Trix" Farrar __\\|//__ Basement.NET
***@basement.net (` o-o ') http://www.basement.net/
--------------------------------ooO-(_)-Ooo--------------------------
GPG Key Fprint: 525F DBA7 1A62 E4C4 E642 DF95 384B B851 3CEF C10A
alligator94
2012-10-31 17:15:01 UTC
Permalink
thanks all for your help.
I have added the backslashes(even before "ooo") and it works fine now :

rrr\!\@\$\ooo


Regards,
Gilles



-----Message d'origine-----
De : rancid-discuss-***@shrubbery.net
[mailto:rancid-discuss-***@shrubbery.net] De la part de Chris Gauthier
Envoyé : mercredi 31 octobre 2012 16:37
À : rancid-***@shrubbery.net
Objet : Re: [rancid] clogin with command file - special signs
Sent: Wednesday, October 31, 2012 8:21 AM
Subject: [rancid] clogin with command file - special signs
Dear all,
I would like to use the command "clogin -x file.txt device-name" to add a
snmp configuration in a lot of cisco devices. The community string includes
I also have tried to use the -c option and to quote the commands, but I get
the same error message
device_name
Is there a workaround ?
Thanks
Gilles
I believe you can escape those characters or put them inside a single-quote
to make it a more literal translation. I have given examples of both below.
I think that option 1 will probably work better, but don't hold me to that.

1) clogin -x "conf t ; snmp-server community rrr\!\@\$ooo RW my_acl; end;
wr; q" device_name
2) clogin -x 'conf t ; snmp-server community rrr!@$ooo RW my_acl; end; wr;
q' device_name

Chris

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------
CONFIDENTIALITY NOTICE
Attention: The information contained in this email and/or attachments is
intended only for the person or entity to which it is addressed and may
contain confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient is
prohibited. If you received this in error, please contact the sender and
delete the material from any system and destroy any copies.

Loading...