cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6759
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

29 Replies 29

Well, two things:

Do you have any logs from today?

And have you tried with tclsh flash://currentdatev.tcl? Try removing the ::cisco::eem::event_register_none from the script and try again:

RTR-S#tclsh flash://currentdate.tcl

.Dec  6 13:26:09: %SYS-5-CONFIG_I: Configured from console by j on vty0 (10.1x.x.x)

.Dec  6 13:26:21: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up

.Dec  6 13:26:25: %LINK-5-CHANGED: Interface Loopback1, changed state to administratively down

.Dec  6 13:26:25: %SYS-5-CONFIG_I: Configured from console by j on vty0 (10.1x.x.x)

.Dec  6 13:26:26: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to down

RTR-S#

Hmm..I can do it with a single '/' after flash as well....can you post a couple of lines from "show log"?

HTH,
John

*** Please rate all useful posts ***

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

Oops!

I didn't configure logging buffered

It's working like a dream :-)

R4#tclsh flash:/currentdate.tcl

*Mar  1 01:28:06.135: %SYS-5-CONFIG_I: Configured from console by console

*Mar  1 01:31:08.379: %SYS-5-CONFIG_I: Configured from console by console

*Mar  1 01:31:14.383: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.1 stopped - CLI initiated

*Mar  1 01:31:14.387: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.1 started - CLI initiated

*Mar  1 01:31:44.711: %SYS-5-CONFIG_I: Configured from console by console

*Mar  1 01:39:26.503: %SYS-5-CONFIG_I: Configured from console by cisco on vty1 (192.168.1.1)

So, any chance you could help EEM? That would be awesome...

I sure can...let me look into it. I can't guarantee anything though EEM is one of those things that go through version iterations between IOS versions. I may not have a version that supports the latest and greatest commands.... I'm glad to see the other script working though!

HTH,
John

*** Please rate all useful posts ***

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

John,

Just so you know, the reason you see the wrong dates my show loggs is because the clock on the router is incorrect. Otherwise, its working well.

Looking forward to EEM....

Cheers mate.

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 ***

John,

Nearly there. Getting a blank screen when issuing the command "event manager run Logs". When I troubleshoot the tcl. I saw that it read "exec" was an invalid command, see below:

R4#invalid command name "exec"

    while executing

"exec {show clock} "

    invoked from within

"$slave eval $Contents"

    (procedure "eval_script" line 7)

    invoked from within

"eval_script slave $scriptname"

    invoked from within

"if {$security_level == 1} {       #untrusted script

     interp create -safe slave

     interp share {} stdin slave

     interp share {} stdout slave

..."

    (file "system:/lib/tcl/base.tcl" line 50)

Tcl policy execute failed: invalid command name "exec" R4#invalid command name "exec"
  

John,

I need to set the environment variable for date. I will look it up. I think it will work once I place the correct environment variable for date...

Tcl policy execute failed: can't read "date": no such variable

John,

Put in the environment variable 'cron_entry', which I think is the environment variable for date and time. However, still getting error:

can't read "date": no such variable

Carlton,

I wish I could help you with this piece, but I don't have an ios version that supports those commands and don't want to lead you in the wrong direction. I can tell you however that cron is the timer that will allow eem scripts to run during a certain time (every minute, every hour, etc). I don't think that's the variable that it's needing. You may want to post this link in the eem forum. Joseph Clarke is awesome with eem scripting, and he may be able to tell you if this will work or not.

Curious though, are you doing this because it's challenging now or is there a real need to call it from the eem script itself. Since you know it works running manually, you could just create an alias and run it directly:

alias exec Logs "tclsh flash:/currentdatev.tcl"

Then to run it, you'd just type "Logs" and hit enter...

HTH,
John

*** Please rate all useful posts ***

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

John,

Really appreciate your help with this. At the moment its just a challenge.

Going to head off to bed now.

Cheers mate.

John,

Can you show me how to post this question to EEM Scripting?

Sorry...I just saw this   Hopefully Joseph will be able to help you further..

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

I found a router that I can use... The following works for me, but it gives me an extra prompt and I'm not sure you'll be able to workaround that:

No.  Class     Type    Event Type          Trap  Time Registered           Name

1    applet    user    none                Off   Fri Dec 7 15:44:34 2012   Test

policyname {Test} sync {yes}

maxrun 20.000

action 1.0 cli command "enable"

action 2.0 cli command "tclsh flash:/currentdate.tcl"

action 3.0 puts "$_cli_result"

RTR-1#event manager run Test

Dec  7 15:42:50.767: %LINK-3-UPDOWN: Interface Loopback20, changed state to up

RTR-1#

RTR-1# (<----- This is the real prompt)

HTH,
John

*** Please rate all useful posts ***

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

Joe Clarke
Cisco Employee
Cisco Employee

You can do from EXEC mode:

term exec prompt time

Then all command output will be preceded with the current timestamp.  The "show clock" command will also show the current date and time.