cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5112
Views
0
Helpful
29
Replies

show run command with date

Hello Community,

Is there a command in the IOS that will pick up todays date?

For example, show loggin | inc <todays_date>

Cheers

Carlton

2 ACCEPTED SOLUTIONS

Accepted Solutions

Well, I have one, but it's not pretty. It's tcl which your router should support. To run it manually on the router, here's what I suggest (although I haven't been able to do much research):

Copy this to your router or a tftp server.

Here's the script:

---- Copy Below -----

set date [ exec {show clock} ]

set day [lindex $date 4]

set mth [lindex $date 3];

if { [ string length $day ] == 2 } {

    set result "${mth} ${day}"

} else {

    set result "${mth}  ${day}"

}

show log | inc $result

---- End of script -----

You can then create an alias on the router that you want to use this script on to launch it:

alias exec todayslogs tclsh tftp:///currentdate.tcl

OR

alias exec todayslogs tclsh flash://currentdate.tcl

***** My Disclaimer: ******

I tested this on my router and it works great, although I can't guarantee that it will work correctly on yours. It's a start though....

HTH,
John

*** Please rate all useful posts ***

HTH, John *** Please rate all useful posts ***

View solution in original post

Does the IOS that you run support actions of gets/puts? If not, I don't think there's going to be an easy way of doing it through an eem script. When you try to run the script via eem, it goes into lala land. That's because eem is running on another tty line and you never see the output. Unfortunately, I don't have a router that supports those commands so I don't think I'll be successful helping you with this...

Here's the way that it would look if you were able to do it though:

event manager applet Logs
 event none
 action 111 cli command "enable"
 action 112 cli command "tclsh flash:/currentdatev.tcl"
 action 113 puts "$_cli_result"
 action 114 set _exit_status "0"

Then to run it would be "event manager run Logs". If you get output, it's working

HTH,
John

*** Please rate all useful posts ***

HTH, John *** Please rate all useful posts ***

View solution in original post

29 REPLIES 29
lee heath
Beginner

you need to use the following command

show loggin | inc Dec  6

where the date use is 1 - 9 use 2 spaces between month and date, 10 - 31 is a single space

Hi Lee,

Thanks for responding. I didn't explain myself. I'm aware that I could do show loggin | inc Dec. However, I was hoping that there might be some kind of variable that would input today's date in show loggin | inc   ?

cheers

Carlton,

There's nothing out of the box as far as I know, but you possibly may be able to script something if that's important to you to be able to do. Generally, logging is sent to a syslog server in which you would be able to search by date. Let me know if the scripting thing is a viable solution for you....

HTH,

John

HTH, John *** Please rate all useful posts ***

John, a script would be great mate.

Hi John,

Do you think you might be able compile a script today? Just wondering mate.

Well, I have one, but it's not pretty. It's tcl which your router should support. To run it manually on the router, here's what I suggest (although I haven't been able to do much research):

Copy this to your router or a tftp server.

Here's the script:

---- Copy Below -----

set date [ exec {show clock} ]

set day [lindex $date 4]

set mth [lindex $date 3];

if { [ string length $day ] == 2 } {

    set result "${mth} ${day}"

} else {

    set result "${mth}  ${day}"

}

show log | inc $result

---- End of script -----

You can then create an alias on the router that you want to use this script on to launch it:

alias exec todayslogs tclsh tftp:///currentdate.tcl

OR

alias exec todayslogs tclsh flash://currentdate.tcl

***** My Disclaimer: ******

I tested this on my router and it works great, although I can't guarantee that it will work correctly on yours. It's a start though....

HTH,
John

*** Please rate all useful posts ***

HTH, John *** Please rate all useful posts ***

View solution in original post

Hi John,

I tried running as follows:

event manager run flash:/logscpcurrentdatev.tcl

but I got the following error message:

Embedded Event Manager policy flash:/logscpcurrentdatev.tcl not registered with event none Event Detector

I have attached the script. I modified it a little

a question, how do you save the tcl script in the router? when you dont have access neither a ftp nor a tftp, only have access to the router by telnet. thanks

Joe Clarke
Hall of Fame Cisco Employee

You can use tclsh for this:

Router#tclsh

Router(tcl)#set fd [open flash:file.txt w]

Router(tcl)#puts $fd {

<Paste contents here.>

}

Router(tcl)#close $fd

John

Thanks mate. Going to check it out now...

I look forward to hearing the outcome if you don't mind posting back

HTH,
John

*** Please rate all useful posts ***

HTH, John *** Please rate all useful posts ***

Hi John,

As you can see I tried modifying so that I could run it from event manager but it wouldn't work.

Any ideas?

Cheers

You won't be able to run this script from event manager...I tried and came back with a blank prompt because event manager runs in a different tty. TCL does as well, but it outputs to the current tty that it was run from.

*** Edit ***

I wont' say you "can't" run it from event manager, but I didn't play around with it too much.

Try running with "tclsh flash://currentdatev.tcl" and see if it at least works. If it does, I can work with eem to see what I can come up with..

HTH,
John

*** Please rate all useful posts ***

HTH, John *** Please rate all useful posts ***

Hi John,

Thanks again for working with me on this.

When I run it with tclsh flash:/currentdatev.tcl I get a blank screen.