<?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: Shell script: How to obtain future date in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549019#M27804</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;this may be a bug when putting something at attachment.&lt;BR /&gt;The first line of the file is inserted with tabs.&lt;BR /&gt;&lt;BR /&gt;So delete the inserted tabs so that it looks like:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/TIME.H&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Fri, 06 Jul 2001 08:29:31 GMT</pubDate>
    <dc:creator>Andreas Voss</dc:creator>
    <dc:date>2001-07-06T08:29:31Z</dc:date>
    <item>
      <title>Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549009#M27794</link>
      <description>Hi: &lt;BR /&gt;&lt;BR /&gt;Does anyone have a suggestion to an easy way of generating the following output: &lt;BR /&gt;&lt;BR /&gt;THE DATE AND TIME 3 DAYS LATER THAN THE PRESENT DATE AND TIME. &lt;BR /&gt;&lt;BR /&gt;I need it for producing a script, that creates a user which expires date 3 days later. One approch would be to obtain the date, via the 'date' command, but it would then be nescessary to somehow convert the string '07' (e.g. output of 'date +%m') to the integer 7. &lt;BR /&gt;&lt;BR /&gt;Your help is appreciated!&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jul 2001 10:46:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549009#M27794</guid>
      <dc:creator>Michael Hemmingsen</dc:creator>
      <dc:date>2001-07-05T10:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549010#M27795</link>
      <description>Hi there.&lt;BR /&gt;Try this :&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;TAG_=`date +'%y%m%d'`; export TAG_&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;export  TAG1="000000"&lt;BR /&gt;TAG1=`expr $TAG_ + 1`&lt;BR /&gt;echo $TAG1&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;Alexander M. Ermes</description>
      <pubDate>Thu, 05 Jul 2001 11:17:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549010#M27795</guid>
      <dc:creator>Alexander M. Ermes</dc:creator>
      <dc:date>2001-07-05T11:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549011#M27796</link>
      <description>Nope, the expr $TAG... doesn't work. The output echoed to screen is: 010705+1</description>
      <pubDate>Thu, 05 Jul 2001 11:48:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549011#M27796</guid>
      <dc:creator>Michael Hemmingsen</dc:creator>
      <dc:date>2001-07-05T11:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549012#M27797</link>
      <description>Try:&lt;BR /&gt;let TAG1=$TAG_+1</description>
      <pubDate>Thu, 05 Jul 2001 12:00:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549012#M27797</guid>
      <dc:creator>federico_3</dc:creator>
      <dc:date>2001-07-05T12:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549013#M27798</link>
      <description>Micheal,&lt;BR /&gt;&lt;BR /&gt;as date calculations sometimes can get a bit tricky, and since most standard shells (except for bash, zsh etc.) have only limited arithmetic functionality, I would suggest doing it with Perl.&lt;BR /&gt;(Perl should be on any decent Unix box ;-)&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;$ perl -e 'printf "%s\n",scalar localtime(time + 3*86400)'&lt;BR /&gt;&lt;BR /&gt;If you need some fancier formatting you would have to invoke localtime() in list context.&lt;BR /&gt;See the POD for what localtime returns (i.e.  $ perldoc -f localtime)</description>
      <pubDate>Thu, 05 Jul 2001 12:06:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549013#M27798</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2001-07-05T12:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549014#M27799</link>
      <description>or &lt;BR /&gt;TAG1=`expr $TAG_ + 1`</description>
      <pubDate>Thu, 05 Jul 2001 12:09:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549014#M27799</guid>
      <dc:creator>federico_3</dc:creator>
      <dc:date>2001-07-05T12:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549015#M27800</link>
      <description>Nope, both let TAG1=$TAG_+1 and&lt;BR /&gt;TAG1=`expr $TAG_ + 1` result in syntax errors.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jul 2001 12:39:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549015#M27800</guid>
      <dc:creator>Michael Hemmingsen</dc:creator>
      <dc:date>2001-07-05T12:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549016#M27801</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;put you a C-Source at attachment.&lt;BR /&gt;Save it ie: under /usr/local/src/fdate.c&lt;BR /&gt;Compile it ie:&lt;BR /&gt;cc /usr/local/src/fdate.c -o /usr/local/bin/fdate&lt;BR /&gt;&lt;BR /&gt;Use it ie: 3 days forward:&lt;BR /&gt;fdate 3&lt;BR /&gt;&lt;BR /&gt;You can also compute backwards with ie:&lt;BR /&gt;&lt;BR /&gt;fdate -3&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 05 Jul 2001 13:12:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549016#M27801</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2001-07-05T13:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549017#M27802</link>
      <description>Hi Micheal:&lt;BR /&gt;&lt;BR /&gt;I has a technique that you will find very useful. It involves converting a date into a truncated Julian Day (more or less the number of days since Jan 1, 4712 BCE; it's used by astronomers to make life simple). In your case, it takes care of month,year,leap year boundaries with ease. &lt;BR /&gt;&lt;BR /&gt;The script I've attached will convert a calender date into a Julian Day and also do the inverse. It also has an argument to calculate the day of the week. Invoke the script as caljd.sh -u for full usage.&lt;BR /&gt;&lt;BR /&gt;In your case I would do it like this:&lt;BR /&gt;&lt;BR /&gt;INC=3&lt;BR /&gt;JD=`caljd.sh` &lt;BR /&gt;JD=$((${JD} + ${INC}))&lt;BR /&gt;CAL_DATE=`caljd.sh ${JD}`&lt;BR /&gt;&lt;BR /&gt;This will calculate 3 days after the current date. If you supply the first call to caljd.sh &lt;BR /&gt;with MM DD YYYY it will calculate 3 days after that date. The number of args is how caljd.sh knows to convert from calendar to julian day or julian day to calendar date.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jul 2001 13:38:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549017#M27802</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-07-05T13:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549018#M27803</link>
      <description>Andrea, your c script does not work. I get the following:&lt;BR /&gt;cc: "fdate.c", line 2: error 1000: Unexpected symbol: "i".&lt;BR /&gt;cc: "fdate.c", line 2: error 1002: Unexpected character: 'u'.&lt;BR /&gt;cc: "fdate.c", line 2: error 1000: Unexpected symbol: "&amp;lt;".&lt;BR /&gt;cc: "fdate.c", line 2: error 1000: Unexpected symbol: ".".&lt;BR /&gt;cc: "fdate.c", line 2: error 1000: Unexpected symbol: "&amp;gt;".&lt;BR /&gt;cc: "fdate.c", line 16: error 1588: "stdout" undefined.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;How come?</description>
      <pubDate>Fri, 06 Jul 2001 05:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549018#M27803</guid>
      <dc:creator>federico_3</dc:creator>
      <dc:date>2001-07-06T05:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549019#M27804</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;this may be a bug when putting something at attachment.&lt;BR /&gt;The first line of the file is inserted with tabs.&lt;BR /&gt;&lt;BR /&gt;So delete the inserted tabs so that it looks like:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/TIME.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Fri, 06 Jul 2001 08:29:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549019#M27804</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2001-07-06T08:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: How to obtain future date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549020#M27805</link>
      <description>The perl thing does work (however a bit elaborate). I created the below script to obtain the date 5 days later in the format dd/mm/yy. It itsn't wery elegant, but does work:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;# futuredate.sh&lt;BR /&gt;#&lt;BR /&gt;###############################################################################&lt;BR /&gt;&lt;BR /&gt;NINETH=`perl -e 'printf "%s",scalar localtime(time + 5*86400)'|cut -c9`&lt;BR /&gt;&lt;BR /&gt;if [ "$NINETH" = " " ]&lt;BR /&gt;  then&lt;BR /&gt;  NEWDATE=0`perl -e 'printf "%s",scalar localtime(time + 5*86400)'|cut -c10`&lt;BR /&gt;else&lt;BR /&gt;  NEWDATE=`perl -e 'printf "%s",scalar localtime(time + 5*86400)'|cut -c9-10`&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;MONTH=`perl -e 'printf "%s",scalar localtime(time + 5*86400)'|cut -c5-7`&lt;BR /&gt;&lt;BR /&gt;case $MONTH in&lt;BR /&gt;  Jan) NEWMONTH=01 ;;&lt;BR /&gt;  Feb) NEWMONTH=02 ;;&lt;BR /&gt;  Mar) NEWMONTH=03 ;;&lt;BR /&gt;  Apr) NEWMONTH=04 ;;&lt;BR /&gt;  May) NEWMONTH=05 ;;&lt;BR /&gt;  Jun) NEWMONTH=06 ;;&lt;BR /&gt;  Jul) NEWMONTH=07 ;;&lt;BR /&gt;  Aug) NEWMONTH=08 ;;&lt;BR /&gt;  Sep) NEWMONTH=09 ;;&lt;BR /&gt;  Oct) NEWMONTH=10 ;;&lt;BR /&gt;  Now) NEWMONTH=11 ;;&lt;BR /&gt;  Dec) NEWMONTH=12 ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;NEWYEAR=`perl -e 'printf "%s",scalar localtime(time + 5*86400)'|cut -c23-24`&lt;BR /&gt;&lt;BR /&gt;echo ${NEWDATE}/${NEWMONTH}/${NEWYEAR}</description>
      <pubDate>Mon, 09 Jul 2001 09:24:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-how-to-obtain-future-date/m-p/2549020#M27805</guid>
      <dc:creator>Michael Hemmingsen</dc:creator>
      <dc:date>2001-07-09T09:24:00Z</dc:date>
    </item>
  </channel>
</rss>

