Path: utzoo!utgpu!attcan!uunet!super!udel!mmdf From: iphwk%MTSUNIX1.BITNET@cunyvm.cuny.edu (Bill Kinnersley) Newsgroups: comp.sys.amiga Subject: Re: Problem with paths and Execute() Message-ID: <3941@louie.udel.EDU> Date: 1 Sep 88 19:08:32 GMT Sender: mmdf@udel.EDU Lines: 55 [In "Problem with paths and Execute()", "Philip F. Hingston" said:] : : I've got this really neat C program that uses Execute() to run shell : scripts. It's nearly finished but I've come across a last minute hitch. : When the program is run from a cli, the processes created by Execute() : inherit the search path from that cli. However, when run from the workbench, : they get the default search path ( CurrentDirectory + C: ). : The program sys:cli seems to have some way of picking up the path that : was in effect when loadwb was run ( I think ). : (phi%munnari.oz@uunet.uu.net) : Wow, this is a good example, including everything at once! The answer (just like all good questions) is 0, but let's show some work: Proc1 Proc2 Proc3 Proc4 CLI : LoadWB- - - - ->WorkBench- - - - - >MyProgram : : EndCLI Execute("foo") : C:RUN- - - - - ->Background CLI : foo : (suicide) MyProgram, being launched from the WorkBench, becomes an independent process Proc3, with no CLI. The Execute() call makes a BSTR saying "foo", deposits this in Proc3's pr_Result2 field, and chains to C:RUN. RUN, finding the pr_Result2 field occupied, realizes it was called by Execute(). It manufactures a new CLI in the background, and builds a fake file handle for the cli_StandardInput containing the command "foo". Each CLI has a Path stored in the field cli_CommandDir. This is a linked list of Locks, linked by BPTRs in fl_Link. When a new CLI is created from an old CLI, the Path is list-copied into the new CLI structure and thus gets inherited. In this case, Proc3 has no CLI, so Proc4's Path will be NULL. By default the CLI will only look for "foo" in the current directory (pr_CurrentDir) and C:, and that's the behavior you are seeing. -- Bill Kinnersley Physics Department BITNET: iphwk@mtsunix1 Montana State University INTERNET: iphwk%mtsunix1.bitnet@cunyvm.cuny.edu Bozeman, MT 59717 CSNET: iphwk%mtsunix1.bitnet@relay.cs.net (406)994-3614 UUCP: ...ucbvax!mtsunix1.bitnet!iphwk "This message was packed as full as practicable by modern electronic equipment. Some settling of contents may have occurred during transmission."