f



error: "couldn't execute "date": no such file or directory" in Tk

hi,
 i am using the following code in a tcl script with the TK framework,
and i get the above error on executing the file main file..


main file
---------------
#!c:/tcl/bin/tclsh

label .l -text "click to execute"
button .b -text "Execute" -command "exec_script"

proc exec_script {} {
  set inp 1
  source sss.tcl
  puts $inp
}
pack .l .b



sss.tcl
-----------------------------
#!c:/tcl/bin/tclsh

set inp 0
puts $inp
set d [exec date]



The error i get is "couldn't execute "date": no such file or
directory"



I am using Tk with Tcl and it is necessary to print the date along
with along with my output.
The "exec date" works perfect in a tcl script only. but when i use it
along with TK i get the error...


i will be glad if someone could please help me...
 
thank you..

0
2/21/2007 11:42:28 AM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

7 Replies
2860 Views

Similar Articles

[PageSpeed] 58

On 21 Feb., 12:42, "ronnie" <maninder....@gmail.com> wrote:
> set d [exec date]
>
> The error i get is "couldn't execute "date": no such file or
> directory"

Since Tcl 7.6 or so, the [clock] function delivers date and time in a
portable way.
See http://www.tcl.tk/man/tcl8.4/TclCmd/clock.htm

Examples:
53615 % clock format [clock seconds]
Wed Feb 21 12:48:09 W. Europe Standard Time 2007
84 % clock format [clock seconds] -format %c
Mittwoch, 21. Februar 2007 12:48:21
53 % clock format [clock seconds] -format %Y-%m-%d,%H:%M:%S
2007-02-21,12:49:42

That [exec date] does work at times, and not at other times, can have
to do with a different PATH.

0
2/21/2007 11:50:20 AM
ronnie wrote:
> hi,
>  i am using the following code in a tcl script with the TK framework,
> and i get the above error on executing the file main file..
> 
> 
> main file
> ---------------
> #!c:/tcl/bin/tclsh
> 
> label .l -text "click to execute"
> button .b -text "Execute" -command "exec_script"
> 
> proc exec_script {} {
>   set inp 1
>   source sss.tcl
>   puts $inp
> }
> pack .l .b
> 
> 
> 
> sss.tcl
> -----------------------------
> #!c:/tcl/bin/tclsh
> 
> set inp 0
> puts $inp
> set d [exec date]
there seems to be no programm "date" in your path?


use [clock]
proc PointInTime {} {
	set second [ clock seconds ]
	# this returns an ISO 8601 format timestring, fix to your liking
	# see man n clock
	return [ clock format $second -gmt 1 -format "%Y%m%dT%T" ]
}

ISO 8601 point-in-time
	An ISO 8601 point-in-time specification, such as CCyymmd-
	dThhmmss,  where  T is the literal T, CCyymmdd hhmmss, or
	CCyymmddThh:mm:ss.
any other format spec for clock format is possible.

uwe
0
2/21/2007 12:04:13 PM
On Feb 21, 5:04 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:
> ronniewrote:
> > hi,
> >  i am using the following code in a tcl script with the TK framework,
> > and i get the above error on executing the file main file..
>
> > main file
> > ---------------
> > #!c:/tcl/bin/tclsh
>
> > label .l -text "click to execute"
> > button .b -text "Execute" -command "exec_script"
>
> > proc exec_script {} {
> >   set inp 1
> >   source sss.tcl
> >   puts $inp
> > }
> > pack .l .b
>
> > sss.tcl
> > -----------------------------
> > #!c:/tcl/bin/tclsh
>
> > set inp 0
> > puts $inp
> > set d [exec date]
>
> there seems to be no programm "date" in your path?
>
> use [clock]
> proc PointInTime {} {
>         set second [ clock seconds ]
>         # this returns an ISO 8601 format timestring, fix to your liking
>         # see man n clock
>         return [ clock format $second -gmt 1 -format "%Y%m%dT%T" ]
>
> }
>
> ISO 8601 point-in-time
>         An ISO 8601 point-in-time specification, such as CCyymmd-
>         dThhmmss,  where  T is the literal T, CCyymmdd hhmmss, or
>         CCyymmddThh:mm:ss.
> any other format spec for clock format is possible.
>
> uwe- Hide quoted text -
>
> - Show quoted text -

hi,
 thank you dear friends.. i was very glad to see my friends uwe and
suchenwi have come out to help me.. your help was very useful and your
suggestions worked well.. thank you very much..
 also i came with another solution to my problem..
 since i did not want to replace the date function that was used.. i
set the path to date.exe in the environment variable PATH of
windows... the date.exe is located in the cygwin\bin directory.. and
hence the "exec date" function ran in successfully..
                             thank you very much once again..
 
keep up the good work :)
 
and take care

0
2/22/2007 7:23:06 AM
On Feb 21, 5:04 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:
> ronnie wrote:
> > hi,
> >  i am using the following code in a tcl script with the TK framework,
> > and i get the above error on executing the file main file..
>
> > main file
> > ---------------
> > #!c:/tcl/bin/tclsh
>
> > label .l -text "click to execute"
> > button .b -text "Execute" -command "exec_script"
>
> > proc exec_script {} {
> >   set inp 1
> >   source sss.tcl
> >   puts $inp
> > }
> > pack .l .b
>
> > sss.tcl
> > -----------------------------
> > #!c:/tcl/bin/tclsh
>
> > set inp 0
> > puts $inp
> > set d [exec date]
>
> there seems to be no programm "date" in your path?
>
> use [clock]
> proc PointInTime {} {
>         set second [ clock seconds ]
>         # this returns an ISO 8601 format timestring, fix to your liking
>         # see man n clock
>         return [ clock format $second -gmt 1 -format "%Y%m%dT%T" ]
>
> }
>
> ISO 8601 point-in-time
>         An ISO 8601 point-in-time specification, such as CCyymmd-
>         dThhmmss,  where  T is the literal T, CCyymmdd hhmmss, or
>         CCyymmddThh:mm:ss.
> any other format spec for clock format is possible.
>
> uwe- Hide quoted text -
>
> - Show quoted text -

hi,
 thank you dear friends.. i was very glad to see my friends uwe and
suchenwi have come out to help me.. your help was very useful and
your
suggestions worked well.. thank you very much..
 also i came with another solution to my problem and i thought i
should share it with you also..
 since i did not want to replace the date function that was used.. i
set the path to date.exe in the environment variable PATH of
windows... the date.exe is located in the cygwin\bin directory and it
is the function that fetches the system date.. after this the "exec
date" function ran in successfully..
                             thank you very much once again..
 
keep up the good work :)

 
and take care



0
2/22/2007 7:35:26 AM
On Feb 21, 6:42 am, "ronnie" <maninder....@gmail.com> wrote:
> hi,
>  i am using the following code in a tcl script with the TK framework,
> and i get the above error on executing the file main file..
:
> The error i get is "couldn't execute "date": no such file or
> directory"

> The "exec date" works perfect in a tcl script only. but when i use it
> along with TK i get the error...

For some reason, you are getting a different set of directories in
your PATH when you run the tcl script than when you run the Tk script.
Or perhaps the Tcl script adds some directories to the PATH
environment variable.

0
lvirden (1938)
2/22/2007 11:31:11 AM
At 2007-02-22 02:35AM, "ronnie" <maninder.vit@gmail.com> wrote:
[...]
>  hi,
>   thank you dear friends.. i was very glad to see my friends uwe and
>  suchenwi have come out to help me.. your help was very useful and
>  your


So what's up with the random From: addresses?  You also sent this reply
as: "Ranjan" <ranjan.kapoor@gmail.com>

-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
0
glennj (645)
2/22/2007 2:28:27 PM
On Feb 22, 7:28 pm, Glenn Jackman <gle...@ncf.ca> wrote:
> At 2007-02-22 02:35AM, "ronnie" <maninder....@gmail.com> wrote:
> [...]
>
> >  hi,
> >   thank you dear friends.. i was very glad to see my friends uwe and
> >  suchenwi have come out to help me.. your help was very useful and
> >  your
>
> So what's up with the random From: addresses?  You also sent this reply
> as: "Ranjan" <ranjan.kap...@gmail.com>
>
> --
> Glenn Jackman
> "You can only be young once. But you can always be immature." -- Dave Barry

:-) o yes.. mr. ranjan my project manager had logged on to my system
earlier, since we are on the same project, so he didn't sign out as a
result my post came up in his name earlier... :-)

0
2/23/2007 4:29:46 AM
Reply: