el stamatakos wrote:
> 
> Hi All,
>  Not sure if I sent this already.
> 
> I am trying to run a command using the TProcess class. I have included it in 
> the uses process.
> 
> I have the code below
> 
> procedure TmainForm.StartCDS();
> cmd:string;
> AProcess:Tprocess;
> begin
> Aprocess:=TProcess.Create(nil);
> 
> cmd:='cd '+Dir+'/des/'+'v'+Rev+' ;startCDS.csh';
> AProcess.CommandLine:=cmd;
> Aprocess.Options:=Aprocess.Options+[poWaitOnExit];
> AProcess.Execute;
> AProcess.Free;
> end;
> 
> I keep getting an error Project raised Exception class 'EProcess' with 
> message Executable not found ""
> 
> Not sure what I am doing wrong.
> 

I see a couple of problems.

First: TProcess is not a shell/terminal. So using things like "|", ">",
"<", ";" etc mean nothing.

Second: As a result of the first reason, trying to execute a script (I
assume that "startCDS.csh" is a script) will not work since it's not
truly executable. You need to execute the interpreter with the script as
it's argument.

Something like this should work:

procedure TmainForm.StartCDS();
var
  cmd:string;
  AProcess:Tprocess;
begin
  AProcess:=TProcess.Create(nil);

  SetCurrentDir(Dir + 'des/v' + Rev);

  cmd:='/bin/sh startCDS.csh'; // is it a csh script or will sh work?
  AProcess.CommandLine:=cmd;
  Aprocess.Options:=Aprocess.Options+[poWaitOnExit];
  AProcess.Execute;
  AProcess.Free;
end;


Happy coding,

Andrew

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to