Sign in Join

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

Mailing lists / lazarus / 2003-05

IPC question...

13 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

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

Marc Weustink
to Tom Lisjac: I dropped a TProcess component on a blank form along with two buttons... one to…

+ From: Tom Lisjac
+
+ > + With Process1 do
+ > + Begin
+ > + CommandLine:='/usr/bin/find /usr';
+ > + Active:=True;
+ > + End;
+ > +
+ > + This creates a process... but it allocates zero ram and
+ doesn't execute
+ > + the find command.
+
+ > Ehm, where and how did you create it ?
+
+ I dropped a TProcess component on a blank form along with two buttons...
+ one to initialize CommandLine and set Active true... and the other to
+ set active false.

Ah, I never used TProces as component, I create it in code. Maybe you neer some options or so.

Example from cmdlinedebugger.pp:

function TCmdLineDebugger.CreateDebugProcess(const AOptions: String):
Boolean;
begin
  if FDbgProcess = nil
  then begin
    FDbgProcess := TProcess.Create(nil);
    FDbgProcess.CommandLine := ExternalDebugger + ' ' + AOptions;
    FDbgProcess.Options:= [poUsePipes, poNoConsole, poStdErrToOutPut];
    FDbgProcess.ShowWindow := swoNone;
    FDbgProcess.Environment:=Environment;
  end;
  if not FDbgProcess.Running
  then begin
    FDbgProcess.Execute;
    WriteLn('[TCmdLineDebugger] Debug PID: ', FDbgProcess.Handle);
  end;
  Result := FDbgProcess.Running;
end;

Marc

Reply by email

Tom Lisjac
to Marc Weustink

Hi Marc,

Ah, I never used TProces as component, I create it in code. Maybe you neer some options or so. Example from cmdlinedebugger.pp:

Thanks!

I got some sleep and started with a fresh project. This time TProcess worked fine when autocreated on the form. I'm not sure if it was the new project, a reboot or the sleep that solved the problem though! :)

TProcess is feature rich and nicely written! I'm going to continue working with it... and if I create any useful examples, I'll post them and send a link to the list.

Best regards,

-Tom

Reply by email

Marco van de Voort
to Tom Lisjac: That's exactly what I was looking for... thank you! Thanks for pointing it out. Using…
Show quoted text 18 lines
> On Fri, 2003-05-02 at 04:26, Mattias Gaertner wrote: > >On Fri, 2 May 2003 12:21:52 +0200 (CEST) > > (Marco van de Voort) wrote: > > > Is there a way to do this in Object Pascal under Linux... or is using a > > > temporary text file the best approach? > > > > Linux unit, popen, assignpipe etc, check the text and the examples. That's exactly what I was looking for... thank you! > What about TProcess? Thanks for pointing it out. Using TProcess might be an even better design approach then the one I was considering. There's Input, OutPut and StdErr public properties and a very complete set of TProcessOptions for setting up pipes and suppressing output to the console! Looks like I'll be spending the next hour writing some test code! :)

IIRC TProcess is based on the same functions in the Linux unit, so it should work too.

Reply by email

Marco van de Voort
to Tom Lisjac: Hi everyone! I'm in the process of migrating some Linux shell scripts I've written into…
Show quoted text 18 lines
I'm in the process of migrating some Linux shell scripts I've written into Lazarus... but I'm trying to figure out an efficient way of redirecting the I/O of external programs like mkisofs, md5sum and a few others without having to create a bunch of temporary disk files? In bash you can launch and redirect the output of "externalprogram" to THEVAR with: THEVAR="`externalprogram`" In perl it's: @output = `externalprogram`; In python, via the "os" module: README = os.popen('externalprogram', 'r') Is there a way to do this in Object Pascal under Linux... or is using a temporary text file the best approach?

Linux unit, popen, assignpipe etc, check the text and the examples.

This works under *BSD too, but only since 1.0.6 or so.

Reply by email

Marc Weustink
to Tom Lisjac: Perhaps we could write some if nothing exists. This is a nice component! I'm having some…

+ From: Tom Lisjac
+
+ > I would love to see the API doc's for this as I think it could make some
+ > of my work a lot easier.
+
+ Perhaps we could write some if nothing exists. This is a nice component! +
+ I'm having some trouble getting it going, however. Here's what I did: +
+ With Process1 do
+ Begin
+ CommandLine:='/usr/bin/find /usr';
+ Active:=True;
+ End;
+
+ This creates a process... but it allocates zero ram and doesn't execute
+ the find command. If I set Active to false, the process terminates. I
+ looked at the sources and didn't see anything else that I thought needed
+ to be set... but that doesn't mean there isn't! :)

Ehm, where and how did you create it ?

Marc

Reply by email

Tom Lisjac
to Marc Weustink
Show quoted text 10 lines
+ With Process1 do + Begin + CommandLine:='/usr/bin/find /usr'; + Active:=True; + End; + + This creates a process... but it allocates zero ram and doesn't execute + the find command. Ehm, where and how did you create it ?

I dropped a TProcess component on a blank form along with two buttons... one to initialize CommandLine and set Active true... and the other to set active false.

Reply by email

Mattias Gaertner
to Tom Lisjac: Hi everyone! I'm in the process of migrating some Linux shell scripts I've written into…
Show quoted text 22 lines
> I'm in the process of migrating some Linux shell scripts I've written > into Lazarus... but I'm trying to figure out an efficient way of > redirecting the I/O of external programs like mkisofs, md5sum and a few > others without having to create a bunch of temporary disk files? > > In bash you can launch and redirect the output of "externalprogram" to > THEVAR with: > > THEVAR="`externalprogram`" > > In perl it's: > @output = `externalprogram`; > > In python, via the "os" module: > README = os.popen('externalprogram', 'r') > > Is there a way to do this in Object Pascal under Linux... or is using a > temporary text file the best approach? Linux unit, popen, assignpipe etc, check the text and the examples. This works under *BSD too, but only since 1.0.6 or so.

What about TProcess?

Mattias

Reply by email

Tom Lisjac
to Marco van de Voort: IIRC TProcess is based on the same functions in the Linux unit, so it should work too.
I would love to see the API doc's for this as I think it could make some of my work a lot easier.

Perhaps we could write some if nothing exists. This is a nice component!

I'm having some trouble getting it going, however. Here's what I did:

With Process1 do
  Begin
    CommandLine:='/usr/bin/find /usr';
    Active:=True;
  End;

This creates a process... but it allocates zero ram and doesn't execute the find command. If I set Active to false, the process terminates. I looked at the sources and didn't see anything else that I thought needed to be set... but that doesn't mean there isn't! :)

-Tom

Reply by email

Tom Lisjac
to Tom Lisjac: Hi everyone! I'm in the process of migrating some Linux shell scripts I've written into…
Show quoted text 7 lines
On Fri, 2003-05-02 at 04:26, Mattias Gaertner wrote: >On Fri, 2 May 2003 12:21:52 +0200 (CEST) > (Marco van de Voort) wrote: > > Is there a way to do this in Object Pascal under Linux... or is using a > > temporary text file the best approach? > > Linux unit, popen, assignpipe etc, check the text and the examples.

That's exactly what I was looking for... thank you!

What about TProcess?

Thanks for pointing it out. Using TProcess might be an even better design approach then the one I was considering. There's Input, OutPut and StdErr public properties and a very complete set of TProcessOptions for setting up pipes and suppressing output to the console!

Looks like I'll be spending the next hour writing some test code! :)

Best regards,

-Tom

Reply by email

Tom Lisjac

Hi everyone!

I'm in the process of migrating some Linux shell scripts I've written into Lazarus... but I'm trying to figure out an efficient way of redirecting the I/O of external programs like mkisofs, md5sum and a few others without having to create a bunch of temporary disk files?

In bash you can launch and redirect the output of "externalprogram" to THEVAR with:

THEVAR="`externalprogram`"

In perl it's:
  @output = `externalprogram`;

In python, via the "os" module:
README = os.popen('externalprogram', 'r')

Is there a way to do this in Object Pascal under Linux... or is using a temporary text file the best approach?

Thanks,

-Tom

Reply by email

A.J. Venter
to Marco van de Voort: IIRC TProcess is based on the same functions in the Linux unit, so it should work too.

Where can I find more information on TProcess ?
I have
googled,
checked the lazarus docs

And nothing.

I would love to see the API doc's for this as I think it could make some of my work a lot easier.

A.J.

Marco van de Voort wrote 25 lines
> > On Fri, 2003-05-02 at 04:26, Mattias Gaertner wrote: > > >On Fri, 2 May 2003 12:21:52 +0200 (CEST) > > > (Marco van de Voort) wrote: > > > > Is there a way to do this in Object Pascal under Linux... or is using a > > > > temporary text file the best approach? > > > > > > Linux unit, popen, assignpipe etc, check the text and the examples. > > That's exactly what I was looking for... thank you! > > > What about TProcess? > > Thanks for pointing it out. Using TProcess might be an even better > design approach then the one I was considering. There's Input, OutPut > and StdErr public properties and a very complete set of TProcessOptions > for setting up pipes and suppressing output to the console! > > Looks like I'll be spending the next hour writing some test code! :) IIRC TProcess is based on the same functions in the Linux unit, so it should work too. _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru

Reply by email

cryst
to Marc Weustink: + From: Tom Lisjac + + > + With Process1 do + > + Begin + > + …

I'm using X on cygwin on XP to talk to a Linux box. I'm able to start gnome-session with the following:

ssh -X -l chris linuxboxen
<password>
gnome-session --replace

(The replace doesn't seem to work, but it comes up anyhow).

But I can't figure out how to start kde. Anybody know?

Chris

Earlier message 55 lines
----- Original Message ----- From: "Marc Weustink" To: Sent: Friday, May 02, 2003 9:26 AM Subject: RE: [lazarus] IPC question... > + From: Tom Lisjac > + > + > + With Process1 do > + > + Begin > + > + CommandLine:='/usr/bin/find /usr'; > + > + Active:=True; > + > + End; > + > + > + > + This creates a process... but it allocates zero ram and > + doesn't execute > + > + the find command. > + > + > Ehm, where and how did you create it ? > + > + I dropped a TProcess component on a blank form along with two buttons... > + one to initialize CommandLine and set Active true... and the other to > + set active false. > > Ah, I never used TProces as component, I create it in code. Maybe you neer > some options or so. > > Example from cmdlinedebugger.pp: > > function TCmdLineDebugger.CreateDebugProcess(const AOptions: String): > Boolean; > begin > if FDbgProcess = nil > then begin > FDbgProcess := TProcess.Create(nil); > FDbgProcess.CommandLine := ExternalDebugger + ' ' + AOptions; > FDbgProcess.Options:= [poUsePipes, poNoConsole, poStdErrToOutPut]; > FDbgProcess.ShowWindow := swoNone; > FDbgProcess.Environment:=Environment; > end; > if not FDbgProcess.Running > then begin > FDbgProcess.Execute; > WriteLn('[TCmdLineDebugger] Debug PID: ', FDbgProcess.Handle); > end; > Result := FDbgProcess.Running; > end; > > Marc > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email