Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CHANGE DIR using Tcl

1,376 views
Skip to first unread message

Ray Mosley

unread,
Dec 1, 1995, 3:00:00 AM12/1/95
to S.Jagadish
In article <1995Dec...@omega.ntu.ac.sg>, sf91...@omega.ntu.ac.sg (S.Jagadish) writes:
|> How do you carry out a CHANGE DIRECTORY operation.
|> exec cd $dir doesnt seem to work. I get an error "couldnt find cd to execute"
|>

(1) cd is a basic tcl command, so you should be able to just do

cd $dir

(2) alternatively, use the fully qualified pathname to cd; it apparently
isn't in your path; for example,

set path <whatever it is>
exec cd $path/cd $dir

|> ---
|> S.Jagadish : SF91...@NTUVAX.NTU.AC.SG
|>
|> Nanyang Technological University Singapore
|> Die hard Kamal Hassan visiri ... from Kalatthur Kannama to Kurudhi Punal !!
|> Mayajaal : http://www2.ntu.ac.sg:8000/~sf918168/mayajaal.html
|> OR http://155.69.1.17:8000/~sf918168/mayajaal.html
|>
|> "Api Swarnamayii Lanka, Na Me Lakshmane Rochate" - Ramayana

S.Jagadish

unread,
Dec 1, 1995, 3:00:00 AM12/1/95
to
How do you carry out a CHANGE DIRECTORY operation.
exec cd $dir doesnt seem to work. I get an error "couldnt find cd to execute"

---

Hume Smith

unread,
Dec 3, 1995, 3:00:00 AM12/3/95
to
> From: mos...@tsd.itg.ti.com (Ray Mosley)
> Date: 1 Dec 1995 15:20:28 GMT

>
> In article <1995Dec...@omega.ntu.ac.sg>, sf91...@omega.ntu.ac.sg (S.Jagadish) writes:
> |> How do you carry out a CHANGE DIRECTORY operation.
> |> exec cd $dir doesnt seem to work. I get an error "couldnt find cd to execute"
> |>
>
> (1) cd is a basic tcl command, so you should be able to just do
>
> cd $dir
>
> (2) alternatively, use the fully qualified pathname to cd; it apparently
> isn't in your path; for example,
>
> set path <whatever it is>
> exec cd $path/cd $dir


uhh... many systems (e.g. UNIX) have no executable
change directory command. it just wouldn't work,
it has to be a built-in.


(there -is- one on AmigaDOS, but it's an unusual beast.)
--
Hume Smith <hcls...@isisnet.com> NetBSD r00lz :)

"Honesty always give you the advantage of surprise
in the House of Commons." - Yes Minister

Larry W. Virden

unread,
Dec 4, 1995, 3:00:00 AM12/4/95
to

According to Ray Mosley <mos...@tsd.itg.ti.com>:

:In article <1995Dec...@omega.ntu.ac.sg>, sf91...@omega.ntu.ac.sg (S.Jagadish) writes:
:|> How do you carry out a CHANGE DIRECTORY operation.
:|> exec cd $dir doesnt seem to work. I get an error "couldnt find cd to execute"
:|>
:
:(1) cd is a basic tcl command, so you should be able to just do
:
: cd $dir
:
:(2) alternatively, use the fully qualified pathname to cd; it apparently
:isn't in your path; for example,
:
: set path <whatever it is>
: exec cd $path/cd $dir
:

Note that the error received was that the user's system doesn't have a command
called cd to be exec'd. In many/most cases for Unix, cd is built into a
shell and so one cannot do an exec. Which is just as well, because by doing
an exec cd you don't gain any benefit anyways - the cd would have been done
in the child executed and once it completed, the child would die and the
parent would still be in the same directory.

The bottom line is, option 1 above is the only one viable for Tcl code
writing.
--
:s Larry W. Virden INET: lvi...@cas.org
:s <URL:http://www.teraform.com/%7Elvirden/> <*>
:s Unless explicitly stated to the contrary, nothing in this posting should
:s be construed as representing my employer's opinions.

Donal K. Fellows

unread,
Dec 4, 1995, 3:00:00 AM12/4/95
to
In article <1995Dec...@omega.ntu.ac.sg>,

S.Jagadish <sf91...@omega.ntu.ac.sg> wrote:
> How do you carry out a CHANGE DIRECTORY operation.
>
> exec cd $dir
>
> doesnt seem to work. I get an error "couldnt find cd to execute"

cd is a builtin in tclsh/wish (and every other shell that ever
existed) so you shouldn't bother with the exec, as even if it worked,
it wouldn't (talk to your local UNIX guru about this if you can't
figure out why this has to be the case, as the explanation has nothing
to do with tcl)

Donal.
--
Donal K. Fellows, (at work) | Donal K. Fellows, (at home)
Dept. of Computer Science, | 6, Randall Place, Heaton,
University of Manchester | Bradford, BD9 4AE
U.K. Tel: ++44-161-275-6137 | U.K. Tel: ++44-1274-401017
fell...@cs.man.ac.uk (preferred) | do...@ugglan.demon.co.uk (if you must)
-------------------------------------------------------------------------------
<http://r8h.cs.man.ac.uk:8000/> for my home page

John Haxby

unread,
Dec 4, 1995, 3:00:00 AM12/4/95
to
mos...@tsd.itg.ti.com (Ray Mosley) wrote:

>(2) alternatively, use the fully qualified pathname to cd; it apparently
>isn't in your path; for example,
>
> set path <whatever it is>
> exec cd $path/cd $dir

In V6, I think, cd wasn't a shell built-in, but even then it was especially
recognised by the shell. The trouble is that the chdir() system call, which
cd invokes, changes the working directory of the current process. This means
that "exec cd $dir" would do nothing useful. "cd" *has* to be a built-in or
at least especially recognised.

--
John Haxby
These are my opinions, not my employer's.


Ray Mosley

unread,
Dec 6, 1995, 3:00:00 AM12/6/95
to lvi...@cas.org
In article <1995Dec4.1...@chemabs.uucp>, lw...@cas.org (Larry W. Virden) writes:
|>
|> According to Ray Mosley <mos...@tsd.itg.ti.com>:
|> :In article <1995Dec...@omega.ntu.ac.sg>, sf91...@omega.ntu.ac.sg (S.Jagadish) writes:
|> :|> How do you carry out a CHANGE DIRECTORY operation.
|> :|> exec cd $dir doesnt seem to work. I get an error "couldnt find cd to execute"
|> :|>
|> :
|> :(1) cd is a basic tcl command, so you should be able to just do
|> :
|> : cd $dir
|> :
|> :(2) alternatively, use the fully qualified pathname to cd; it apparently

|> :isn't in your path; for example,
|> :
|> : set path <whatever it is>
|> : exec cd $path/cd $dir
|> :
|>
|> Note that the error received was that the user's system doesn't have a command
|> called cd to be exec'd. In many/most cases for Unix, cd is built into a
|> shell and so one cannot do an exec. Which is just as well, because by doing
|> an exec cd you don't gain any benefit anyways - the cd would have been done
|> in the child executed and once it completed, the child would die and the
|> parent would still be in the same directory.
|>
|> The bottom line is, option 1 above is the only one viable for Tcl code
|> writing.
|> --

And many people have told me that, too! :-)

Another "Mosley response whithout a great deal ot thought"!

0 new messages