how to catch fpopen() output

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how to catch fpopen() output

Graeme Geldenhuys-2
Hi,

I have a function called fpgOpenURL(...) which contains the following ....

    if fpsystem('which xdg-open') = 0 then
      Helper := 'xdg-open'
    else if fpsystem('which firefox') = 0 then
      Helper := 'firefox';
    else if fpsystem('which konqueror') = 0 then
      Helper := 'konqueror';
    else if fpsystem('which opera') = 0 then
      Helper := 'opera';
    else if fpsystem('which mozilla') = 0 then
       Helper := 'mozilla';

It tries to dected the preferred or installed web browser. If Helper
<> '' at the end, I know I found a web browser.  But how do I catch
the output of fpopen('which xxx') so that I can set the full path of
the application in  the 'Helper' variable.

eg:
   instead of using 'xdg-open'  I would prefer to set the full path
returned by 'which xdg-open' which is '/usr/bin/xdg-open'


Regards,
 - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: how to catch fpopen() output

Graeme Geldenhuys-2
Sorry, I meant catching fpSystem() output...



On Wed, Jul 23, 2008 at 2:40 PM, Graeme Geldenhuys
<[hidden email]> wrote:

> Hi,
>
> I have a function called fpgOpenURL(...) which contains the following ....
>
>    if fpsystem('which xdg-open') = 0 then
>      Helper := 'xdg-open'
>    else if fpsystem('which firefox') = 0 then
>      Helper := 'firefox';
>    else if fpsystem('which konqueror') = 0 then
>      Helper := 'konqueror';
>    else if fpsystem('which opera') = 0 then
>      Helper := 'opera';
>    else if fpsystem('which mozilla') = 0 then
>       Helper := 'mozilla';
>
> It tries to dected the preferred or installed web browser. If Helper
> <> '' at the end, I know I found a web browser.  But how do I catch
> the output of fpopen('which xxx') so that I can set the full path of
> the application in  the 'Helper' variable.
>
> eg:
>   instead of using 'xdg-open'  I would prefer to set the full path
> returned by 'which xdg-open' which is '/usr/bin/xdg-open'




Regards,
 - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to catch fpopen() output

ik-6
You should use pipes rather then fpSystem for that.

Ido

On Wed, Jul 23, 2008 at 3:44 PM, Graeme Geldenhuys
<[hidden email]> wrote:

> Sorry, I meant catching fpSystem() output...
>
>
>
> On Wed, Jul 23, 2008 at 2:40 PM, Graeme Geldenhuys
> <[hidden email]> wrote:
>> Hi,
>>
>> I have a function called fpgOpenURL(...) which contains the following ....
>>
>>    if fpsystem('which xdg-open') = 0 then
>>      Helper := 'xdg-open'
>>    else if fpsystem('which firefox') = 0 then
>>      Helper := 'firefox';
>>    else if fpsystem('which konqueror') = 0 then
>>      Helper := 'konqueror';
>>    else if fpsystem('which opera') = 0 then
>>      Helper := 'opera';
>>    else if fpsystem('which mozilla') = 0 then
>>       Helper := 'mozilla';
>>
>> It tries to dected the preferred or installed web browser. If Helper
>> <> '' at the end, I know I found a web browser.  But how do I catch
>> the output of fpopen('which xxx') so that I can set the full path of
>> the application in  the 'Helper' variable.
>>
>> eg:
>>   instead of using 'xdg-open'  I would prefer to set the full path
>> returned by 'which xdg-open' which is '/usr/bin/xdg-open'
>
>
>
>
> Regards,
>  - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



--
http://ik.homelinux.org/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: how to catch fpopen() output

Marc Santhoff
In reply to this post by Graeme Geldenhuys-2
Am Mittwoch, den 23.07.2008, 14:40 +0200 schrieb Graeme Geldenhuys:

> Hi,
>
> I have a function called fpgOpenURL(...) which contains the following ....
>
>     if fpsystem('which xdg-open') = 0 then
>       Helper := 'xdg-open'
>     else if fpsystem('which firefox') = 0 then
>       Helper := 'firefox';
>     else if fpsystem('which konqueror') = 0 then
>       Helper := 'konqueror';
>     else if fpsystem('which opera') = 0 then
>       Helper := 'opera';
>     else if fpsystem('which mozilla') = 0 then
>        Helper := 'mozilla';
>
> It tries to dected the preferred or installed web browser. If Helper
> <> '' at the end, I know I found a web browser.  But how do I catch
> the output of fpopen('which xxx') so that I can set the full path of
> the application in  the 'Helper' variable.
>
> eg:
>    instead of using 'xdg-open'  I would prefer to set the full path
> returned by 'which xdg-open' which is '/usr/bin/xdg-open'

I haven't done it myself, but I'm somewhat sure the standard answer for
this case is:

Use TProcess. There is a wiki page about it.

;)
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: how to catch fpopen() output

Anthony Henry
Could also use popen.


Sent from my iPhone

On Jul 23, 2008, at 11:11, Marc Santhoff <[hidden email]> wrote:

> Am Mittwoch, den 23.07.2008, 14:40 +0200 schrieb Graeme Geldenhuys:
>> Hi,
>>
>> I have a function called fpgOpenURL(...) which contains the  
>> following ....
>>
>>    if fpsystem('which xdg-open') = 0 then
>>      Helper := 'xdg-open'
>>    else if fpsystem('which firefox') = 0 then
>>      Helper := 'firefox';
>>    else if fpsystem('which konqueror') = 0 then
>>      Helper := 'konqueror';
>>    else if fpsystem('which opera') = 0 then
>>      Helper := 'opera';
>>    else if fpsystem('which mozilla') = 0 then
>>       Helper := 'mozilla';
>>
>> It tries to dected the preferred or installed web browser. If Helper
>> <> '' at the end, I know I found a web browser.  But how do I catch
>> the output of fpopen('which xxx') so that I can set the full path of
>> the application in  the 'Helper' variable.
>>
>> eg:
>>   instead of using 'xdg-open'  I would prefer to set the full path
>> returned by 'which xdg-open' which is '/usr/bin/xdg-open'
>
> I haven't done it myself, but I'm somewhat sure the standard answer  
> for
> this case is:
>
> Use TProcess. There is a wiki page about it.
>
> ;)
> Marc
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal