Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-03

Free Pascal ? (I Hope its not too OT)

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Terry A. Haimann

I tried to write a little utility to submit a command to 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?

Reply by email

Aleksa Todorovic
to Terry A. Haimann

Try including SysUtils in FreePascal version - it initializes exception handling, so maybe there are some exceptions internally happening which are not properly handled. Just a guess...

Terry A. Haimann wrote 43 lines
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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Aleksa Todorovic - Lead Programmer Eipix Entertainment

Reply by email

Terry A. Haimann
to Aleksa Todorovic

This may seem like a stupid question, but is there an easy way to do this? Since these directories that all of these include files reside in arn't in my path statement and they arn't all in the same directory.

Aleksa Todorovic wrote 55 lines
Try including SysUtils in FreePascal version - it initializes exception handling, so maybe there are some exceptions internally happening which are not properly handled. Just a guess... On Sun, Mar 14, 2010 at 04:04, Terry A. Haimann wrote: > 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 > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > >

Reply by email

Aleksa Todorovic
to Terry A. Haimann
Try
Uses Classes, Process, SysUtils;

:-)

Terry A. Haimann wrote 75 lines
This may seem like a stupid question, but is there an easy way to do this? ?Since these directories that all of these include files reside in arn't in my path statement and they arn't all in the same directory. Aleksa Todorovic wrote: > > Try including SysUtils in FreePascal version - it initializes > exception handling, so maybe there are some exceptions internally > happening which are not properly handled. Just a guess... > > > On Sun, Mar 14, 2010 at 04:04, Terry A. Haimann > wrote: > >> >> 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 >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> >> > > > > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Aleksa Todorovic - Lead Programmer Eipix Entertainment

Reply by email

Marco van de Voort
to Terry A. Haimann: I tried to write a little utility to submit a command to code to do this is as follows:…
Terry A. Haimann wrote 17 lines
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

Maybe the main program is finished before the sub program has finished?

Reply by email