On 4 Jul 1997, Balthar wrote:

> My problem is that I am trting to exec the GNU date comand inside a
> command to obtain the day of the week that a certain date falls on.
> The code I am using to try this is:
> 
> set tvMonth January
> set tvYear 1997
> set a "date -d '1 "
> set b "' +%a"
> set datestr [concat $a $tvMonth $tvYear$b]
> set tvDay [exec $datestr]
> 
> Now, I was hoping that tvDay would contain the day, but when I run
> this piece of code I keep getting a message telling me that the
> command "date -d '1 January 1997' +%a" is not a file or directory. I
> have tried putting the path in the command but am still getting the
> same error.

You need set tvDay [exec [eval $datestr]], but then the "date" command
fails because your args aren't right. I didn't investigate why; I'll leave
that up to you!  ;-)

At any rate, if you're using tcl 7.6 or newer, there is now a built-in
"clock" command that you can use instead of the external date command.

> I amsorry if this is very basic stuff, or if I should not really be
> placing the message in this mailing list, but I am slowly driving
> myself mad trying to work out why this code will not cooperate.

> P.S. If this is not the correct place to be mailingthese sorts of       
> questions, and in an effort not to waste too many people's time, can
> anyone suggest somewhere else that I could get answers to this sort of
> thing from?

A better place for tcl questions is the comp.lang.tcl newsgroup.

...RickM...

Reply via email to