<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need help ASAP in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965995#M101563</link>
    <description>Hi Kevin,&lt;BR /&gt;&lt;BR /&gt;     Thanks for the query, this has given me some opportunity me do some c programming/sys programming. Last done during my college days in the year 2000.&lt;BR /&gt;&lt;BR /&gt;Just write a c program..&lt;BR /&gt;&lt;BR /&gt;---------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;;&lt;BR /&gt;#include &lt;STDIO.H&gt;;&lt;BR /&gt;int main () {&lt;BR /&gt;        time_t t,a;&lt;BR /&gt;        t=time(&amp;amp;t);&lt;BR /&gt;        a=t-172800;&lt;BR /&gt;        printf("%s\n",ctime(&amp;amp;a));&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;---------------------------------&lt;BR /&gt;&lt;BR /&gt;Just compile it and execute the ./a.out &lt;BR /&gt;&lt;BR /&gt;,voila it will always print the the day which is 2 days before.&lt;BR /&gt;&lt;BR /&gt;172800 is 42 hours in seconds.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Senthil Kumar .A&lt;BR /&gt;&lt;BR /&gt;&lt;/STDIO.H&gt;&lt;/TIME.H&gt;</description>
    <pubDate>Thu, 09 Mar 2006 13:05:37 GMT</pubDate>
    <dc:creator>Senthil Kumar .A_1</dc:creator>
    <dc:date>2006-03-09T13:05:37Z</dc:date>
    <item>
      <title>Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965988#M101556</link>
      <description>ok this really isn't the most critical of issues except I need to get this figured out ASAP to make my boss happy.&lt;BR /&gt;&lt;BR /&gt;I need to store in a varable the date for &lt;BR /&gt;2 hours ago&lt;BR /&gt;&lt;BR /&gt;Now this seemed simple.  Except I started thinking about certain conditions:&lt;BR /&gt;  1) What if it's 1 am?  The date two hours ago is from the previous day.  I can't just take the hour and subract 2.&lt;BR /&gt;  2) leap year&lt;BR /&gt;  3) what if it's 1 am on jan 1st; same as issue 1) but the year is also affected.&lt;BR /&gt;&lt;BR /&gt;anyone have a solution to this?&lt;BR /&gt;&lt;BR /&gt;I'm trying to accomplish this is regular shell (posix) scripting utilizing utilities like sed /awk and any built-in posix functions.&lt;BR /&gt;&lt;BR /&gt;But if perl or something else is the answer then I'll just have to go that route.&lt;BR /&gt;&lt;BR /&gt;Any and all help appreciated.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Kevin&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:11:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965988#M101556</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2006-03-09T12:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965989#M101557</link>
      <description>Shalom Kevin&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.ws/merijn/caljd-2.23.sh" target="_blank"&gt;http://hpux.ws/merijn/caljd-2.23.sh&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.ws/merijn/caljd-2.2.pl" target="_blank"&gt;http://hpux.ws/merijn/caljd-2.2.pl&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Both handle date calculations that you describe with reasonable efficiency.&lt;BR /&gt;&lt;BR /&gt;Maintained by our fearless point leader, A. Clay Stephenson.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 09 Mar 2006 12:18:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965989#M101557</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-03-09T12:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965990#M101558</link>
      <description>TM=$(perl -e 'print scalar localtime(time - 7200)')&lt;BR /&gt;echo "Two hours ago was ${TM}"&lt;BR /&gt;&lt;BR /&gt;You can also extract individual fields from Perl's localtime function, if you like.&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:28:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965990#M101558</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-09T12:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965991#M101559</link>
      <description>Interesting Mr Stephenson.&lt;BR /&gt;&lt;BR /&gt;Your command works but I get the following errors:  (script posted below)&lt;BR /&gt;./2hoursago.sh   &lt;BR /&gt;Two hours ago was Thu Mar  9 08:43:45 2006&lt;BR /&gt;./2hoursago.sh[7]: /: Execute permission denied.&lt;BR /&gt;./2hoursago.sh[8]: /: Execute permission denied.&lt;BR /&gt;./2hoursago.sh[9]: /: Execute permission denied.&lt;BR /&gt;./2hoursago.sh[10]: /: Execute permission denied.&lt;BR /&gt;./2hoursago.sh[11]: /: Execute permission denied.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's my script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;TM=$(perl -e 'print scalar localtime(time - 7200)')&lt;BR /&gt;echo "Two hours ago was ${TM}"&lt;BR /&gt;&lt;BR /&gt;any ideas?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:45:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965991#M101559</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2006-03-09T12:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965992#M101560</link>
      <description>Fixed it and it now works.&lt;BR /&gt;There were some odd characters which found their way into my script.&lt;BR /&gt;&lt;BR /&gt;THANK YOU</description>
      <pubDate>Thu, 09 Mar 2006 12:49:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965992#M101560</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2006-03-09T12:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965993#M101561</link>
      <description>Thank you both for your replies.&lt;BR /&gt;&lt;BR /&gt;I realized I must now learn perl.  For that was way too easy.&lt;BR /&gt;&lt;BR /&gt;Thank you Mr. Protter for the other links as well.  They will be very useful.</description>
      <pubDate>Thu, 09 Mar 2006 12:51:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965993#M101561</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2006-03-09T12:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965994#M101562</link>
      <description>Just as a thank you for the help and to save someone some time here's the simple code to see the different times:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;TM2h=$(perl -e 'print scalar localtime(time - 7200)')     #    7200 seconds =  2 hours&lt;BR /&gt;TM8h=$(perl -e 'print scalar localtime(time - 28800)')    #   28800 seconds =  8 hours&lt;BR /&gt;TM24h=$(perl -e 'print scalar localtime(time - 86400)')   #   86400 seconds = 24 hours&lt;BR /&gt;TM1w=$(perl -e 'print scalar localtime(time - 604800)')   #  604800 seconds =  1 week&lt;BR /&gt;&lt;BR /&gt;echo " 2 hours ago was ${TM2h}"&lt;BR /&gt;echo " 8 hours ago was ${TM8h}"&lt;BR /&gt;echo "24 hours ago was ${TM24h}"&lt;BR /&gt;echo " 1 week  ago was ${TM1w}"</description>
      <pubDate>Thu, 09 Mar 2006 13:01:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965994#M101562</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2006-03-09T13:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965995#M101563</link>
      <description>Hi Kevin,&lt;BR /&gt;&lt;BR /&gt;     Thanks for the query, this has given me some opportunity me do some c programming/sys programming. Last done during my college days in the year 2000.&lt;BR /&gt;&lt;BR /&gt;Just write a c program..&lt;BR /&gt;&lt;BR /&gt;---------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;;&lt;BR /&gt;#include &lt;STDIO.H&gt;;&lt;BR /&gt;int main () {&lt;BR /&gt;        time_t t,a;&lt;BR /&gt;        t=time(&amp;amp;t);&lt;BR /&gt;        a=t-172800;&lt;BR /&gt;        printf("%s\n",ctime(&amp;amp;a));&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;---------------------------------&lt;BR /&gt;&lt;BR /&gt;Just compile it and execute the ./a.out &lt;BR /&gt;&lt;BR /&gt;,voila it will always print the the day which is 2 days before.&lt;BR /&gt;&lt;BR /&gt;172800 is 42 hours in seconds.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Senthil Kumar .A&lt;BR /&gt;&lt;BR /&gt;&lt;/STDIO.H&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Thu, 09 Mar 2006 13:05:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965995#M101563</guid>
      <dc:creator>Senthil Kumar .A_1</dc:creator>
      <dc:date>2006-03-09T13:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965996#M101564</link>
      <description>Sorry 2 hours is it,i thought 2 days..&lt;BR /&gt;&lt;BR /&gt;then subract just.. 7200&lt;BR /&gt;&lt;BR /&gt;--------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;;&lt;BR /&gt;#include &lt;STDIO.H&gt;;&lt;BR /&gt;int main () {&lt;BR /&gt;time_t t,a;&lt;BR /&gt;t=time(&amp;amp;t);&lt;BR /&gt;a=t-7200;&lt;BR /&gt;printf("%s\n",ctime(&amp;amp;a));&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;BR /&gt;Here u do not require to worry about ..leap years,time zone, months etc..&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Senthil Kumar .A&lt;/STDIO.H&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Thu, 09 Mar 2006 13:08:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965996#M101564</guid>
      <dc:creator>Senthil Kumar .A_1</dc:creator>
      <dc:date>2006-03-09T13:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help ASAP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965997#M101565</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;     This has given me a reason to learn perl. Hats off to Clay stevenson. WOW that perl command was too cool . I did not see others post when I was working with my c program. Sorry.&lt;BR /&gt;&lt;BR /&gt;    By the way ,As far as UNIX is concerned, perl has beaten C... WOW unbelievable.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Senthil Kumar .A</description>
      <pubDate>Thu, 09 Mar 2006 13:17:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-asap/m-p/4965997#M101565</guid>
      <dc:creator>Senthil Kumar .A_1</dc:creator>
      <dc:date>2006-03-09T13:17:58Z</dc:date>
    </item>
  </channel>
</rss>

