safe shell command

Richard K. Herz herz at ucsd.edu
Fri Feb 21 15:06:01 EST 2003


On Friday, February 21, 2003 9:51 AM, Alex Rice wrote:

> On Thursday, February 20, 2003, at 11:18  PM, Richard K. Herz wrote:
>
> > My understanding is that you need to get the path to the directory
> > where your exe is, e.g., from parsing "get the long name of this
> > stack", and then have the shell "cd" to that directory before running
> > the exe.  This is what the script I sent does.  The path to the
> > directory the exe is in gMyappPath originally.
>
> I'm probably missing something, but I don't think that is necessary.
> shell() runs from the defaultFolder, and the only time the
> defaultFolder is not equal to the path of the main stack, is when you
> running in development platform, and in that case you can just fix up
> the defaultFolder property. So you don't need to cd to a path to
> execute a shell command, unless the command is actually located in an
> entirely different directory.

Testing now with MC on Win XP, it does look like the cmd.exe shell's default
directory is the same as Rev/MC (engine's location or by setting "the
directory").  For example, start Rev/MC and from the msg box, answer
shell("dir") lists the contents of the directory where the Rev/MC engine is
located and answer shell("dir ..\") lists the directory above.  So you're
right, you don't have to shell cd with the complete path to the exe to
"start" the exe as I did in my original script, just "start" it with a
relative name, e.g., get shell("start \appfolder\app.exe") for an exe in
folder "appfolder" below the current Rev/MC default directory.  If I'm
understanding you right, a shell cd with the full pathname has problems of
potential path differences between Rev/MC and Windows.

Rich Herz
herz at ucsd.edu





More information about the use-livecode mailing list