Sign in Join

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

Mailing lists / lazarus / 2011-10

Tprocess to communicate with applications running

11 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Celâl Emre ÖZ

Hi, firstly I'm sorry for my English bad. I am working on a long-time pascal Tprocess and have resolved the problem. The output of the application can not run it in the closing process and unable to communicate. Trying to process my intention to communicate. In the meantime, a program written in Python process. I'll be glad you can be helpful in this regard. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111015/b0533379/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Celâl Emre ÖZ

Hello,

Please always put some code snipets (a full minimal program would be ideal) and mention your FPC version and operating system when asking questions.

In your case also adding your question in turkish in addition to english (but please not only turkish) might be helpful too, since maybe google translate will be able to translate it. I did not understand most of your post.

Felipe Monteiro de Carvalho

Reply by email

Celâl Emre ÖZ
to Felipe Monteiro de Carvalho

Ok. thank u your answer.
I wrote a Python program. It's a xmpp client and it's running like a server. So it's always run but pascal don't get output or send input when python running.

Turkish
"Pythonda yazd???m xmpp client yaz?l?m?na, pascaldan girdi g?ndermiyor ya da ??kt? alam?yorum.
Tprocess ?al??an bir programa program kapanana kadar eri?emiyor"

CODE

procedure TForm1.Button1Click(Sender: TObject);
var python:TProcess;
  cikti:TStringList;
  CharBuffer: array [0..511] of char;
  ReadCount: integer;
  ott:string;
  begin
python:=TProcess.Create(nil);
cikti := TStringList.Create;
python.CommandLine:= 'c:\python27\python.exe  jabber.py';
python.Execute;
ShowMessage('b');
while python.Running do begin
   ShowMessage('c');
  if python.Output.NumBytesAvailable >0 then  ShowMessage('A'); // ERRORR
DON'T SHOW
    begin
  ReadCount := Min(512, python.Output.NumBytesAvailable);
  python.Output.Read(CharBuffer, ReadCount);
  Write(ott, Copy(CharBuffer, 0, ReadCount));
  memo1.Lines.Add(ott);
  end;
end;

On Sun, Oct 16, 2011 at 6:00 PM, Felipe Monteiro de Carvalho <

Show quoted text 21 lines
wrote: Hello, Please always put some code snipets (a full minimal program would be ideal) and mention your FPC version and operating system when asking questions. In your case also adding your question in turkish in addition to english (but please not only turkish) might be helpful too, since maybe google translate will be able to translate it. I did not understand most of your post. -- Felipe Monteiro de Carvalho -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111016/07da9e8a/attachment.html>

Reply by email

Michael Van Canneyt
to Celâl Emre ÖZ
Cel?l Emre ?Z wrote 28 lines
Ok. thank u your answer. I wrote a Python program. It's a xmpp client and it's running like a server. So it's always run but pascal don't get output or send input? when python running. Turkish "Pythonda yazd???m xmpp client yaz?l?m?na, pascaldan girdi g?ndermiyor ya da ??kt? alam?yorum. Tprocess ?al??an bir programa program? kapanana kadar? eri?emiyor" CODE procedure TForm1.Button1Click(Sender: TObject); var python:TProcess; ? cikti:TStringList; ? CharBuffer: array [0..511] of char; ? ReadCount: integer; ? ott:string; ? begin python:=TProcess.Create(nil); cikti := TStringList.Create; python.CommandLine:= 'c:\python27\python.exe? jabber.py'; python.Execute; ShowMessage('b'); while python.Running do begin ?? ShowMessage('c'); ? if python.Output.NumBytesAvailable >0 then? ShowMessage('A'); // ERRORR DON'T SHOW ??? begin ? ReadCount := Min(512, python.Output.NumBytesAvailable);

Do not use NumBytesAvailable.

You can do it simply as follows:

  while python.Running do
    begin
    Repeat
      readCount:=python.Output.Read(CharBuffer,512);
      Write(ott, Copy(CharBuffer, 0, ReadCount));
  ?   memo1.Lines.Add(Copy(CharBuffer, 0, ReadCount));
    until (readcount<512);
    end;

Read will simply read as much bytes as are available.

Michael.

Reply by email

Celâl Emre ÖZ
to Michael Van Canneyt

I've tried it but fpc has failed *Project project1.exe raised exception class external:SIGSEGV *

2011/10/16 Michael Van Canneyt

Show quoted text 60 lines
On Sun, 16 Oct 2011, Cel?l Emre ?Z wrote: Ok. thank u your answer. > I wrote a Python program. It's a xmpp client and it's running like a > server. So it's always run but pascal don't get > output or send input when python running. > > Turkish > "Pythonda yazd???m xmpp client yaz?l?m?na, pascaldan girdi g?ndermiyor ya > da ??kt? alam?yorum. > Tprocess ?al??an bir programa program kapanana kadar eri?emiyor" > > CODE > > procedure TForm1.Button1Click(Sender: TObject); > var python:TProcess; > cikti:TStringList; > CharBuffer: array [0..511] of char; > ReadCount: integer; > ott:string; > begin > python:=TProcess.Create(nil); > cikti := TStringList.Create; > > python.CommandLine:= 'c:\python27\python.exe jabber.py'; > python.Execute; > ShowMessage('b'); > while python.Running do begin > ShowMessage('c'); > if python.Output.**NumBytesAvailable >0 then ShowMessage('A'); // > ERRORR DON'T SHOW > begin > ReadCount := Min(512, python.Output.**NumBytesAvailable); > Do not use NumBytesAvailable. You can do it simply as follows: while python.Running do begin Repeat readCount:=python.Output.Read(**CharBuffer,512); Write(ott, Copy(CharBuffer, 0, ReadCount)); memo1.Lines.Add(Copy(**CharBuffer, 0, ReadCount)); until (readcount<512); end; Read will simply read as much bytes as are available. Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111016/fff5d5e6/attachment.html>

Reply by email

Unknown author
to Andrew Haines
Andrew Haines wrote 9 lines
On 10/16/11 12:50, Cel?l Emre ?Z wrote: > > I've tried it but fpc has failed *Project project1.exe raised > exception class external:SIGSEGV * Have you enabled pipes? I didn't see it anywhere. Python.Options := [poUsePipes]; Python.Execute;

Good point.

Michael.

Reply by email

Celâl Emre ÖZ
to Unknown author

if I use the poUsePipes, python starts, but does not write anything on the screen. the program must write a report

Screen 1 with pipe : http://b1110.hizliresim.com/11/10/16/16687.jpg* Screen 2 with out pipe : http://b1110.hizliresim.com/11/10/16/16718.jpg *
2011/10/16

Show quoted text 27 lines
On Sun, 16 Oct 2011, Andrew Haines wrote: On 10/16/11 12:50, Cel?l Emre ?Z wrote: > >> >> I've tried it but fpc has failed *Project project1.exe raised >> exception class external:SIGSEGV * >> > > Have you enabled pipes? I didn't see it anywhere. > > Python.Options := [poUsePipes]; > Python.Execute; > Good point. Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111016/ab442712/attachment.html>

Reply by email

Michael Van Canneyt
to Celâl Emre ÖZ
Cel?l Emre ?Z wrote
if I use the poUsePipes, python starts, but does not write anything on the screen. the program must write a report

You must use pipes, otherwise you cannot catch the output. The

   Python.Options := [poUsePipes];

combined with my suggestions should write something to screen.

Michael.

Show quoted text 34 lines
Screen 1 with pipe : http://b1110.hizliresim.com/11/10/16/16687.jpg Screen 2 with out pipe : http://b1110.hizliresim.com/11/10/16/16718.jpg 2011/10/16 On Sun, 16 Oct 2011, Andrew Haines wrote: On 10/16/11 12:50, Cel?l Emre ?Z wrote: I've tried it but fpc has failed ? *Project project1.exe raised exception class external:SIGSEGV * Have you enabled pipes? I didn't see it anywhere. Python.Options := [poUsePipes]; Python.Execute; Good point. Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Celâl Emre ÖZ
to Michael Van Canneyt

Ok. I've tried Python.Options := [poNoConsole,
poUsePipes,poStderrToOutPut]; and it's run successful but only problem continuous loop and it can't response to users. I've tried Application.ProcessMessages;
but don't resolve.

2011/10/16 Michael Van Canneyt

Show quoted text 58 lines
On Sun, 16 Oct 2011, Cel?l Emre ?Z wrote: if I use the poUsePipes, python starts, but does not write anything on the > screen. the program must write a report > You must use pipes, otherwise you cannot catch the output. The Python.Options := [poUsePipes]; combined with my suggestions should write something to screen. Michael. > > Screen 1 with pipe : http://b1110.hizliresim.com/**11/10/16/16687.jpg<http://b1110.hizliresim.com/11/10/16/16687.jpg> > Screen 2 with out pipe : http://b1110.hizliresim.com/**11/10/16/16718.jpg<http://b1110.hizliresim.com/11/10/16/16718.jpg> > > 2011/10/16 > > > On Sun, 16 Oct 2011, Andrew Haines wrote: > > On 10/16/11 12:50, Cel?l Emre ?Z wrote: > > I've tried it but fpc has failed *Project project1.exe > raised > exception class external:SIGSEGV * > > > Have you enabled pipes? I didn't see it anywhere. > > Python.Options := [poUsePipes]; > Python.Execute; > > > Good point. > > Michael. > -- > ______________________________**_________________ > Lazarus mailing list > .**freepascal.org > http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus> > > > > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111016/f5f6ea87/attachment.html>

Reply by email

Celâl Emre ÖZ
to Celâl Emre ÖZ

i resolve problem, thanks to everyone.

Cel?l Emre ?Z wrote 68 lines
Ok. I've tried Python.Options := [poNoConsole, poUsePipes,poStderrToOutPut]; and it's run successful but only problem continuous loop and it can't response to users. I've tried Application.ProcessMessages; but don't resolve. 2011/10/16 Michael Van Canneyt > > > On Sun, 16 Oct 2011, Cel?l Emre ?Z wrote: > > if I use the poUsePipes, python starts, but does not write anything on >> the screen. the program must write a report >> > > You must use pipes, otherwise you cannot catch the output. > The > Python.Options := [poUsePipes]; > combined with my suggestions should write something to screen. > > Michael. > > > >> >> Screen 1 with pipe : http://b1110.hizliresim.com/**11/10/16/16687.jpg<http://b1110.hizliresim.com/11/10/16/16687.jpg> >> Screen 2 with out pipe : http://b1110.hizliresim.com/** >> 11/10/16/16718.jpg <http://b1110.hizliresim.com/11/10/16/16718.jpg> >> >> 2011/10/16 >> >> >> On Sun, 16 Oct 2011, Andrew Haines wrote: >> >> On 10/16/11 12:50, Cel?l Emre ?Z wrote: >> >> I've tried it but fpc has failed *Project project1.exe >> raised >> exception class external:SIGSEGV * >> >> >> Have you enabled pipes? I didn't see it anywhere. >> >> Python.Options := [poUsePipes]; >> Python.Execute; >> >> >> Good point. >> >> Michael. >> -- >> ______________________________**_________________ >> Lazarus mailing list >> .**freepascal.org >> http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus> >> >> >> >> > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111016/0c5a3f03/attachment.html>

Reply by email