How to find the router reboot date using script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find the router reboot date using script?
# 1  
Old 02-14-2013
How to find the router reboot date using script?

Hai

Iam having router output in a text file.from this data how to find out the router reboot date and time using script

HTML Code:
 [local]bgl-ras-bng-bge-09>show version | grep Time
Router Up Time -   61 days, 21 hours 31 minutes 49 secs

[local]bgl-ras-bng-bge-09>show clock
Thu Feb 14 10:16:14 2013 IST
output date should come with below formula

HTML Code:
Thu Feb 14 10:16:14 2013 IST    -   61 days, 21 hours 31 minutes 49 secs = ROUTER REBOOT DATE with TIME.
can any body help. tnx in advance.
# 2  
Old 02-14-2013
date --date='Thu Feb 14 10:16:14 2013 IST - 61 days 21 hours 31 minutes 49 secs'
# 3  
Old 02-14-2013
Hi its not working.below error coming

HTML Code:
# date --date='Thu Feb 14 10:16:14 2013 IST - 61 days 21 hours 31 minutes 49 secs'

output


HTML Code:
 date: illegal option -- date=Thu Feb 14 10:16:14 2013 IST - 61 days 21 hours 31 minutes 49 secs
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
# 4  
Old 02-14-2013
-d is a GNU-only option.

From this we can tell you probably don't have linux.

If you don't, what do you have?
# 5  
Old 02-14-2013
Hi

Iam using solaris 10 OS server.
# 6  
Old 02-14-2013
Code:
# Get the current time, minus 300 seconds 
DATE=$(perl -e 'use POSIX qw(strftime);  print strftime "%m %d %H %M %S\n", localtime(time()+$ARGV[0]);' -- -300 )

Now there's just the challenge of getting the number of seconds out of that string. I'm guessing it may vary, not printing days if it hasn't been up days, etc... hmm...
# 7  
Old 02-14-2013
Code:
OLDIFS="$IFS"
IFS="${IFS},"

set -- `show version | grep Time`

IFS="$OLDIFS"

while [ "$#" -gt 0 ] && [ "$1" != "-" ] ; do shift ; done

shift

S=0

while [ "$#" -gt 0 ]
do
        case "$2" in
        day*) let S=S+${1}*60*60*24 ;;
        hour*) let S=S+${1}*60*60 ;;
        minute*) let S=S+${1}*60 ;;
        second*) let S=S+${1} ;;
        esac

        shift 2
done

DATE=$(perl -e 'use POSIX qw(strftime);  print strftime "%m %d %H %M %S\n", localtime(time()+$ARGV[0]);' -- -${S} )

Adjust strftime to taste by changing its format string, see man strftime, it takes the same options.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find n.of weekdays and n.of weekends in a given date

Hi All, Could you please provide the shell script to find number of weekdays and number of weekends for a given date for that month. Monday to friday should be considered as weekdays and Saturday and Sunday should be considered as weekends. Date should be passed as parameter. For... (13 Replies)
Discussion started by: ROCK_PLSQL
13 Replies

2. UNIX for Beginners Questions & Answers

Script to find a date variable and increment it

Hi, I have parameter file wo_location.prm which has a date variable $last_upd_date= 02032016. I need to write a unix shell script to find that variable and increment it by 1 day. The path to the file is root/dir_lc/shared/param/wo_location.prm and the variable is $last_upd_date. Any... (2 Replies)
Discussion started by: isenhiem
2 Replies

3. Red Hat

How to find out what router a connection uses?

How can i trace a destination IP from the initiating IP to see what router(s) it goes thru from the source IP to the destination IP on Linux Redhat server? If it is the traceroute command, what options can i Use to get that infoirmation? Thanks (2 Replies)
Discussion started by: mrn6430
2 Replies

4. Shell Programming and Scripting

How to find the date of previous day in shell script?

Hi Experts, i am using the below code get the date of previous day. #!/usr/bin/ksh datestamp=`date '+%Y%m%d'` yest=$((datestamp -1)) echo $yest When i execute the code i am getting output as: 20130715 What i am trying here is, based on the date passed i am fetching previus day's... (0 Replies)
Discussion started by: learner24
0 Replies

5. UNIX for Dummies Questions & Answers

Remote Unix printing to my WinXP works with no router. How can I make it work through my router?

I set up remote printing on a clients Unix server to my Windows XP USB printer. My USB printer is connected directly to my PC (no print server and no network input on printer). With my Win XP PC connected to my cable modem (without the router), i can do lp -dhp842c /etc/hosts and it prints. I... (7 Replies)
Discussion started by: jmhohne
7 Replies

6. Shell Programming and Scripting

How to script to find the newer date in a text file?

Hi, I have a text file, foo.txt, it looks something like below. In the file there is a line that gives the date in the form of: Mon Jun 15 11:09:31 2008. I need to find which date is the newest and then store certain details of that list data to another file. So, in this sample text file, I... (6 Replies)
Discussion started by: boolean2222
6 Replies

7. AIX

How to find the router IP address

How to find the router IP address (2 Replies)
Discussion started by: AIXlearner
2 Replies

8. UNIX for Dummies Questions & Answers

shell script to find files by date and size

Hi, I have a directory PRIVATE in which I have several directories and each of these have several files. Therefore, I need to find those files by size and date to back up those files in another directory. I don't know how to implement this shell script using ''find''. appreciate any... (1 Reply)
Discussion started by: dadadc
1 Replies

9. Shell Programming and Scripting

Script to find files on a given input date

Hello gurus, I need to write a script to find out all the file that got changed on a specific folder since a given input date (Date to be given as Input) Thanx (1 Reply)
Discussion started by: ar.karan
1 Replies
Login or Register to Ask a Question