Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

Append a string to a router's flash file

Hi guys,

Just setup a small but useful Remote Access VPN accounting script:

event manager applet VPN_Accounting_UP 
 event syslog pattern "%CRYPTO-5-SESSION_STATUS: Crypto tunnel is UP"
 action 1.0 cli command "enable"
 action 1.2 cli command "show clock | append flash:/VPN_Accounting"
 action 2.0 cli command "show crypto session brief | append flash:/VPN_Accounting"
 action 3.0 append flash:/VPN_Accounting "=================================================="

And here's the output as I just almost need it:

Cisco-Tests#more flash:/VPN_Accounting

14:28:50.680 EEST Mon Aug 4 2014

Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating 
        K - No IKE
ivrf = (none)
           Peer     I/F        Username          Group/Phase1_id   Uptime Status
  85.24.27.62    Vl11         ra-user                  VPNRA 00:02:34    UA

 

15:10:33.492 EEST Mon Aug 4 2014

Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating 
        K - No IKE
ivrf = (none)
           Peer     I/F        Username          Group/Phase1_id   Uptime Status
  85.24.27.62    Vl11         ra-user                  VPNRA  00:00:00    UA

 

My only question is how can I add after the last output append some string like: "==================================".

Mainly just action 3.0 is not working...

 

Thanks!

3 REPLIES
cgm
New Member

Do not know any easy way to

Do not know any easy way to do that, but you could create a tcl script that just "puts" its argument and then do "tclsh puts.tcl ========================= | append flash:/VPN_Accounting"

Kind of an "echo" command :)

Cisco Employee

The append action is for

The append action is for appending a string to another string.  If you have EEM 4.0, you can use the file open and file write actions, but it's not clear what version of IOS you have.  As a general workaround, you can try what cgm suggests, or convert this applet to Tcl at http://www.marcuscom.com/convert_applet/ then add:

 

set fd [open "flash:/VPN_Accounting" a]

puts $fd "========================================"

close $fd

New Member

As Joseph said, the file

As Joseph said, the file operation are available from 15.2(2)T. Reference here

If you are able to use the file actions, you could do it as in the example below:

event manager applet VPN_Accounting_UP
 event syslog pattern "%CRYPTO-5-SESSION_STATUS: Crypto tunnel is UP"
 action 1 file open LOGFILE flash:VPN_Accounting.txt a+
 action 2 cli command "enable"
 action 3 cli command "show clock"
 action 4 file puts LOGFILE "$_cli_result"
 action 5 cli command "show crypto session brief"
 action 6 file puts LOGFILE "$_cli_result"
 action 7 set filebuffer "=================================================="
 action 8 file puts LOGFILE "$filebuffer"
 action 9 file close LOGFILE

 

775
Views
0
Helpful
3
Replies