<?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 getting epoch time through shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107714#M717538</link>
    <description>does anyone know of a shell script that will convert a date timestamp into seconds epoch?&lt;BR /&gt;&lt;BR /&gt;I know how to do this easy enough with perl, but what I need this for perl will not work, it has to be a shell script..&lt;BR /&gt;&lt;BR /&gt;basically it would need to convert something like:&lt;BR /&gt;Fri Oct 31 15:44:42 EST 2003&lt;BR /&gt;into:&lt;BR /&gt;1067633082</description>
    <pubDate>Fri, 31 Oct 2003 15:46:37 GMT</pubDate>
    <dc:creator>Ken Penland_1</dc:creator>
    <dc:date>2003-10-31T15:46:37Z</dc:date>
    <item>
      <title>getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107714#M717538</link>
      <description>does anyone know of a shell script that will convert a date timestamp into seconds epoch?&lt;BR /&gt;&lt;BR /&gt;I know how to do this easy enough with perl, but what I need this for perl will not work, it has to be a shell script..&lt;BR /&gt;&lt;BR /&gt;basically it would need to convert something like:&lt;BR /&gt;Fri Oct 31 15:44:42 EST 2003&lt;BR /&gt;into:&lt;BR /&gt;1067633082</description>
      <pubDate>Fri, 31 Oct 2003 15:46:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107714#M717538</guid>
      <dc:creator>Ken Penland_1</dc:creator>
      <dc:date>2003-10-31T15:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107715#M717539</link>
      <description>Not sure about a script.  I found a thread that uses c.&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?admit=716493758+1067633578166+28353475&amp;amp;threadId=7848" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?admit=716493758+1067633578166+28353475&amp;amp;threadId=7848&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Rusty</description>
      <pubDate>Fri, 31 Oct 2003 15:58:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107715#M717539</guid>
      <dc:creator>Rusty Sapper</dc:creator>
      <dc:date>2003-10-31T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107716#M717540</link>
      <description>yeah, I dont think that is going to work, but thanks...some of you amaze me with your abilities to quickly find threads round here ;)&lt;BR /&gt;&lt;BR /&gt;Here is a little background on my situation...basically we have this third party software that "web enables" some of our applications...well, and I am not sure of all the details, but basically it has the ability to run home-grown scripts, but it reads in the script and converts it into some format that it understands...which, obviously causes it to bawk when it see's a perl script....I even tried getting around it by just having a shell script call the perl script and it still bawks...I have a feeling it will freak out when it see's a C prog also...&lt;BR /&gt;&lt;BR /&gt;dont ask me, I didnt write this stupid thing :P&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2003 16:03:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107716#M717540</guid>
      <dc:creator>Ken Penland_1</dc:creator>
      <dc:date>2003-10-31T16:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107717#M717541</link>
      <description>Something is very strange here. If your application can invoke the shell --- which in turn I assume can call commands like date, awk, ... then it should be able to utilize any executable including Perl. I suspect that the proper Perl environment is not setup so that you may need to add extra -I arguments and PATH before Perl is invoked.&lt;BR /&gt;Perl is definitely the way to do this.&lt;BR /&gt;&lt;BR /&gt;If you must, I can probably get you very close with caljd.sh -- although the timezone stuff makes this problem more difficult. If the datestamps can be done UT rather than local timezones then this is a much simpler exercise.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2003 16:18:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107717#M717541</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-10-31T16:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107718#M717542</link>
      <description>I even tried getting around it by just having a shell script call the perl script and it still bawks...I have a feeling it will freak out when it see's a C prog also...&lt;BR /&gt;&lt;BR /&gt;Does other unix commands work, i.e. grep, sed, awk, etc.  after all they are compiled C programs, just like the shell is.  &lt;BR /&gt;&lt;BR /&gt;Maybe your application will only execute commands found in a specific location, i.e. has it's own PATH variable (or equiv) setup.</description>
      <pubDate>Fri, 31 Oct 2003 16:25:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107718#M717542</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-31T16:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107719#M717543</link>
      <description>Yeah, I see where you are getting with this, and I can see how it would be confusing ;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;all I know about this product is this:&lt;BR /&gt;&lt;BR /&gt;the users, from the web, run a script called menu.sh...&lt;BR /&gt;&lt;BR /&gt;in this script it has echo's, read's, if checks and case statements..other than that, no commands except shell programs in the case statements...like if the user picks option 1, it runs this script..&lt;BR /&gt;&lt;BR /&gt;but you are right...in the shell scripts that it calls, they use stuff like grep and awk...which is compiled....so perhaps a C program will work, I will try it on Monday...&lt;BR /&gt;&lt;BR /&gt;as for perl, when I try to run a perl script (which works manually from command line) it actually just hangs forever and starts churning on the CPU until it is manually killed.  so I am unclear as to what the problem is with that...&lt;BR /&gt;&lt;BR /&gt;I was kind of just hoping that there was already a script written out there somewhere that did this...Oh, and the timezone doesnt make a difference really...basically I need the epoch time for comparisons, like was Jul 22nd, 15:44 2003 90 days ago?  if so, then do this...</description>
      <pubDate>Fri, 31 Oct 2003 16:47:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107719#M717543</guid>
      <dc:creator>Ken Penland_1</dc:creator>
      <dc:date>2003-10-31T16:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107720#M717544</link>
      <description>Okay, in that case I can help you if you can do enough awk or shell scripting on your own to at least pull out "Jul 22 2003" from the data string.&lt;BR /&gt;&lt;BR /&gt;I'll do this in POSIX/ksh but you might have to use expr if this is a really dumb shell.&lt;BR /&gt;&lt;BR /&gt;DT="Jul 22 2003"&lt;BR /&gt;DIFF=$(( $(caljd) - $(caljd.sh -i ${DT}) ))&lt;BR /&gt;if [[ ${DIFF} -ge 90 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "This here is 90 days or older"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Invoke as caljd.sh -u for full usage. You can also yank out the cal_jdate function and use it directly. It takes three numerical args: month, day, year and converts them to a JulianDay --- number of days since Jan 1, 4713 BCE. Differences are then easy.&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2003 17:20:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107720#M717544</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-10-31T17:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107721#M717545</link>
      <description>Hi,&lt;BR /&gt;maybe the attached script can help you. In order to achieve the requested, it has to be fed correctly, e.g.:&lt;BR /&gt;# ./return_seconds 1970 2003 10 31 15 44 42 &lt;BR /&gt;&lt;BR /&gt;which produces this result:&lt;BR /&gt;1067615082&lt;BR /&gt;&lt;BR /&gt;The parameters are explained in the script:  no. 1 is the year to count back to; the script counts back to midnight of $1. The other six parameters are the year, month etc, from which you count.&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Sat, 01 Nov 2003 07:15:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107721#M717545</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-11-01T07:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: getting epoch time through shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107722#M717546</link>
      <description>Excellent!&lt;BR /&gt;&lt;BR /&gt;yes, both of the above will work :)&lt;BR /&gt;&lt;BR /&gt;One thing to mention though, on the return_seconds script, the way that is written, the timezone does make a differance, because midnight 1970 is not really 0 seconds epoch, it is 6 hours off when running in EST...I think I will play around with the script to hard code in the date of Dec 31 19:00:00 1969 as being the start time :)&lt;BR /&gt;&lt;BR /&gt;Thanks for your assistance :)</description>
      <pubDate>Mon, 03 Nov 2003 15:38:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-epoch-time-through-shell/m-p/3107722#M717546</guid>
      <dc:creator>Ken Penland_1</dc:creator>
      <dc:date>2003-11-03T15:38:53Z</dc:date>
    </item>
  </channel>
</rss>

