System date

0 views
Skip to first unread message

chris

unread,
Dec 3, 2009, 1:02:10 PM12/3/09
to amrita-ebook
No doubt one of the less glorious problems but: Any existing call in
there to get the system date?

I'm thinking like
time -> t
echo $t
2.645334...

but more along the lines of
date -> d
echo $d
2009-12-03 12:46:38

None of this is critical to what I'm doing, but I've setup everything
to auto-document itself and I'd like to get a feel for how long it
took for any given run to get done, as well as when I did it. I used
to wrap the amrita call between two shell date calls and redirect the
whole thing to a log file which meant no terminal feedback. To fix
that, I've created a procedure that prints simultaneously to the
screen and a log file, so shell redirection is no longer required. It
also means that the system date needs to come from amrita itself
(unless there's a way to pipe it from the outside on demand).

chris

unread,
Dec 3, 2009, 1:11:01 PM12/3/09
to amrita-ebook
Must have been sleeping: I just answered myself (in a way)

Keep on redirecting the date shell calls to a log file, but DO NOT
redirect the amrita call itself. Then get amrita to append to the same
log file without recreating it.

It doesn't answer in any way my original question, but it does what I
wanted...
Sorry!

James Quirk

unread,
Dec 3, 2009, 1:16:06 PM12/3/09
to chris, amrita-ebook
Chris,
The idea of program-folds is that AMRITA does not need to provide
a command to do everything. For if it can't do something, you have
the option to drop into a specialist fold, as in:

fold::perl { print date
($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
printf "%4d-%02d-%02d %02d:%02d:%02d\n",
$year+1900,$mon+1,$mday,$hour,$min,$sec;
}

You could also write:

tokenpath + <- %perl::
fold::perl { print date
($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
}
echo $hour,$min,$sec

so that AMRITA can access the Perlrl varibable implicitly, or
you could use an explicit push pull mechanism:

fold::perl { print date
my ($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
$amrita->set_token('hour',$hour);
$amrita->set_token('min',$min);
$amrita->set_token('sec',$sec);
}
echo $hour,$min,$sec

James


>
> --
>
> You received this message because you are subscribed to the Google Groups "amrita-ebook" group.
> To post to this group, send email to amrita...@googlegroups.com.
> To unsubscribe from this group, send email to amrita-ebook...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/amrita-ebook?hl=en.
>
>

Christian Hébert

unread,
Dec 3, 2009, 1:30:07 PM12/3/09
to amrita-ebook
I had a hint that such a mechanism was involved. I just really had no clue about the exact syntax.
I've already solved my problem but I still don't like the way it's done. I will no doubt implement what you've proposed (3rd way is my favorite)
Thanks again!

----- On 2009-12-03 1:16 PM, James Quirk wrote: -----

James Quirk

unread,
Dec 3, 2009, 1:45:20 PM12/3/09
to Christian Hébert, amrita-ebook
Chris,

On Thu, 3 Dec 2009, Christian H�bert wrote:

> I had a hint that such a mechanism was involved. I just really had no
> clue about the exact syntax.
> I've already solved my problem but I still don't like the way it's done.
> I will no doubt implement what you've proposed (3rd way is my favorite)
> Thanks again!
If you post your script, I will show you how it might be cleaned.

James
Reply all
Reply to author
Forward
0 new messages