Can't change directory with shell(cd)

Sarah Reichelt sarah.reichelt at gmail.com
Thu May 1 19:04:57 EDT 2008


On Fri, May 2, 2008 at 8:54 AM, Michael D Mays <michael.rr at mdmays.com> wrote:
> I'm doing this
>
>   answer folder ""
>   put it into aPath
>   put "cd "&aPath into aRequest
>   put aRequest into fld 1
>   put shell(aRequest) into fld 2
>   put shell("ls") into fld 3
>
>  No matter which folder I chose, Rev's 'Home' folder is the directory
> listed.
>  When I cut and paste fld 1 into the Terminal, ls works as expected.

I found 2 problems with this. Firstly, if the folder name contains a
space, this will not work, so I surrounded the aPath with single
quotes. Secondly, I think you are using 2 separate instances of the
shell as you do the commands in two separate shell calls. If you
combine them into a single command and just use one shell call, it
works.

Here is my edited version of your script:

    answer folder ""
    put it into aPath
    put "cd '" & aPath & "'" into aRequest
    put aRequest & cr & "ls" into tCmd
    put shell(tCmd) into fld 1

However, why do you want to use a shell command for this, when the
same functionality is built into Revolution commands? You could try
something like this:

    answer folder ""
    put it into aPath
    set the defaultfolder to aPath
    put the files & cr & the folders into fld 1

Cheers,
Sarah



More information about the use-livecode mailing list