Terry A. Haimann
Sun, 14 Mar 2010 15:09:51 -0700
I tried to write a little utility to submit a command to the At Facility. The code to do this is as follows: program TestPrg; Uses Classes, Process; Var i: Integer; Cmd, Pre, Post, StrVar, SwStr: String; MyProcess: TProcess; SOut, EOut, StdStrLst: TStringList; Begin StdStrLst := TStringlist.Create; SOut := TStringlist.Create;EOut := TStringlist.Create; EOut := 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);
SOut.LoadFromStream(MyProcess.Output);
For i:=1 to SOut.Count Do
WriteLn(SOut.Strings[i]);
EOut.LoadFromStream(MyProcess.StdErr);
For i:=1 to EOut.Count Do
WriteLn(EOut.Strings[i]);
End.
Running this code from a Lazarus test program works with out any
problems. When running it from a Free Pascal (non gui,) the program
finishes normally, but nothing gets submitted to the AT Facility.
uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics,
Dialogs,
StdCtrls, Process;Someone on the Lazarus List recommend I add SysUtils to my utility program. I am not sure how to do this. SysUtils has many included files in there and they are all in other directories, none of which are in my path. I am sure there is some simple method here that I am totally ignorant of.
Thanks in advance, TH _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal