I tried to write a little utility to submit a command to the At Facility.

The code to do this is as follows:

 StdStrLst   := TStringlist.Create;
 ErrorStrLst := TStringlist.Create;
 MyProcess := TProcess.Create(nil);
 MyProcess.CommandLine := 'at now';
 MyProcess.Options := MyProcess.Options + [poUsePipes];
 MyProcess.Execute;
 StdStrLst.Clear;
 StdStrLst.Add('awk -F":" ''{print $1"\t"$3"\t"$4}'' /etc/passwd | sort');
 StdStrLst.SaveToStream(MyProcess.Input);
 StdStrLst.Clear;
 StdStrLst.Add(chr(4));
 StdStrLst.SaveToStream(MyProcess.Input);

Running this code from a Lazarus test program works with out any problems. When running it from a Free Pascal (non gui,) the program seems to halt after issuing the "MyProcess.Execute;" The program seems to exit without any errors, but I have put writeln's throughout the code and I don't see any output after the above instruction. It is probable that there is some errors in the stdout, but I never see them and don't know how to access it after the program exits.

The Uses clause for the two apps are as follows.

Lazarus:
uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
 StdCtrls, Process;

Free Pascal:
   Uses Classes, Process;

Anyone have any ideas?

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to