EiffelProcess

6 Messages Forum Options Options
Embed this topic
Permalink
Daniel Tuser-2
EiffelProcess
Reply Threaded MoreMore options
Print post
Permalink
I would like to use EiffelProcess. Could someone tell me if it is usable
with Windows and Linux? And are there simple examples?

Regards,
Daniel
Jocelyn (eiffel)
Re: EiffelProcess
Reply Threaded MoreMore options
Print post
Permalink
Yes, it is usable on Windows, Linux, and others

For this simple example (quickly written), what about this one, which
launch a process hidden, and get the output
(Don't forget to enable multi threaded option.)

    last_error: INTEGER

    output_of_command (a_cmd, a_dir: STRING): STRING is
            -- Output of command `a_cmd' launched in directory `a_dir'.
        require
          cmd_attached: a_cmd /= Void
          dir_attached: a_dir /= Void
        local
            pf: PROCESS_FACTORY
            p: PROCESS
            retried: BOOLEAN
        do
            if not retried then
                last_error := 0
                create Result.make (10)
                create pf
                p := pf.process_launcher_with_command_line (a_cmd, a_dir)
                p.set_hidden (True)
                p.set_separate_console (False)
                p.redirect_output_to_agent (agent (res: STRING; s: STRING)
                        do
                            res.append_string (s)
                        end (Result, ?)
                    )
                p.launch
                p.wait_for_exit
            else
                last_error := 1
            end
        rescue
            retried := True
            retry
        end

Hope this helps,
Jocelyn

On 9/10/2008 13:51, Daniel Tuser wrote:

> I would like to use EiffelProcess. Could someone tell me if it is usable
> with Windows and Linux? And are there simple examples?
>
> Regards,
> Daniel
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>  


Daniel Tuser-2
Re: EiffelProcess
Reply Threaded MoreMore options
Print post
Permalink
Hi Jocelyn
Thanks for the example. Unfortunately it doesn't behave as expected on
my machine. The project settings are set to multi threaded and the
base-mt is used as precompiled library. output_of_command ("ls", "/")
returns an empty string, but last_error is still 0. I cleaned and
compiled the project several times, but nothing changed.
I have no idea what I should change or try to get the correct results.
Has someone an idea, what the problem could be?

Regards,
Daniel

Jocelyn wrote:

>
> Yes, it is usable on Windows, Linux, and others
>
> For this simple example (quickly written), what about this one, which
> launch a process hidden, and get the output
> (Don't forget to enable multi threaded option.)
>
> last_error: INTEGER
>
> output_of_command (a_cmd, a_dir: STRING): STRING is
> -- Output of command `a_cmd' launched in directory `a_dir'.
> require
> cmd_attached: a_cmd /= Void
> dir_attached: a_dir /= Void
> local
> pf: PROCESS_FACTORY
> p: PROCESS
> retried: BOOLEAN
> do
> if not retried then
> last_error := 0
> create Result.make (10)
> create pf
> p := pf.process_launcher_with_command_line (a_cmd, a_dir)
> p.set_hidden (True)
> p.set_separate_console (False)
> p.redirect_output_to_agent (agent (res: STRING; s: STRING)
> do
> res.append_string (s)
> end (Result, ?)
> )
> p.launch
> p.wait_for_exit
> else
> last_error := 1
> end
> rescue
> retried := True
> retry
> end
>
> Hope this helps,
> Jocelyn
>
> On 9/10/2008 13:51, Daniel Tuser wrote:
> > I would like to use EiffelProcess. Could someone tell me if it is
> usable
> > with Windows and Linux? And are there simple examples?
> >
> > Regards,
> > Daniel
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
>  

Jocelyn (eiffel)
Re: EiffelProcess
Reply Threaded MoreMore options
Print post
Permalink
I haven't checked yet, but what if you put the absolute path to 'ls' ?

output_of_command ("/bin/ls", "/")

-- Jocelyn

On 9/10/2008 15:10, Daniel Tuser wrote:

> Hi Jocelyn
> Thanks for the example. Unfortunately it doesn't behave as expected on
> my machine. The project settings are set to multi threaded and the
> base-mt is used as precompiled library. output_of_command ("ls", "/")
> returns an empty string, but last_error is still 0. I cleaned and
> compiled the project several times, but nothing changed.
> I have no idea what I should change or try to get the correct results.
> Has someone an idea, what the problem could be?
>
> Regards,
> Daniel
>
> Jocelyn wrote:
>  
>> Yes, it is usable on Windows, Linux, and others
>>
>> For this simple example (quickly written), what about this one, which
>> launch a process hidden, and get the output
>> (Don't forget to enable multi threaded option.)
>>
>> last_error: INTEGER
>>
>> output_of_command (a_cmd, a_dir: STRING): STRING is
>> -- Output of command `a_cmd' launched in directory `a_dir'.
>> require
>> cmd_attached: a_cmd /= Void
>> dir_attached: a_dir /= Void
>> local
>> pf: PROCESS_FACTORY
>> p: PROCESS
>> retried: BOOLEAN
>> do
>> if not retried then
>> last_error := 0
>> create Result.make (10)
>> create pf
>> p := pf.process_launcher_with_command_line (a_cmd, a_dir)
>> p.set_hidden (True)
>> p.set_separate_console (False)
>> p.redirect_output_to_agent (agent (res: STRING; s: STRING)
>> do
>> res.append_string (s)
>> end (Result, ?)
>> )
>> p.launch
>> p.wait_for_exit
>> else
>> last_error := 1
>> end
>> rescue
>> retried := True
>> retry
>> end
>>
>> Hope this helps,
>> Jocelyn
>>
>> On 9/10/2008 13:51, Daniel Tuser wrote:
>>    
>>> I would like to use EiffelProcess. Could someone tell me if it is
>>>      
>> usable
>>    
>>> with Windows and Linux? And are there simple examples?
>>>
>>> Regards,
>>> Daniel
>>>
>>> ------------------------------------
>>>
>>> Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>>
>>>      
>>  
>>    
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>  


Jocelyn (eiffel)
Re: EiffelProcess
Reply Threaded MoreMore options
Print post
Permalink
I've just tried on ubuntu 8.04 using the latest Eiffel6.3
and it works nicely ... when specifying   "/bin/ls"  instead of just  "ls"

So I guess this is your issue.
Regards,
Jocelyn

On 9/10/2008 16:13, Jocelyn wrote:

> I haven't checked yet, but what if you put the absolute path to 'ls' ?
>
> output_of_command ("/bin/ls", "/")
>
> -- Jocelyn
>
> On 9/10/2008 15:10, Daniel Tuser wrote:
>  
>> Hi Jocelyn
>> Thanks for the example. Unfortunately it doesn't behave as expected on
>> my machine. The project settings are set to multi threaded and the
>> base-mt is used as precompiled library. output_of_command ("ls", "/")
>> returns an empty string, but last_error is still 0. I cleaned and
>> compiled the project several times, but nothing changed.
>> I have no idea what I should change or try to get the correct results.
>> Has someone an idea, what the problem could be?
>>
>> Regards,
>> Daniel

Daniel Tuser-2
Re: EiffelProcess
Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Jocelyn (eiffel)
It works. Thank you very much!

Jocelyn wrote:

>
> I haven't checked yet, but what if you put the absolute path to 'ls' ?
>
> output_of_command ("/bin/ls", "/")
>
> -- Jocelyn
>
> On 9/10/2008 15:10, Daniel Tuser wrote:
> > Hi Jocelyn
> > Thanks for the example. Unfortunately it doesn't behave as expected on
> > my machine. The project settings are set to multi threaded and the
> > base-mt is used as precompiled library. output_of_command ("ls", "/")
> > returns an empty string, but last_error is still 0. I cleaned and
> > compiled the project several times, but nothing changed.
> > I have no idea what I should change or try to get the correct results.
> > Has someone an idea, what the problem could be?
> >
> > Regards,
> > Daniel
> >
> > Jocelyn wrote:
> >
> >> Yes, it is usable on Windows, Linux, and others
> >>
> >> For this simple example (quickly written), what about this one, which
> >> launch a process hidden, and get the output
> >> (Don't forget to enable multi threaded option.)
> >>
> >> last_error: INTEGER
> >>
> >> output_of_command (a_cmd, a_dir: STRING): STRING is
> >> -- Output of command `a_cmd' launched in directory `a_dir'.
> >> require
> >> cmd_attached: a_cmd /= Void
> >> dir_attached: a_dir /= Void
> >> local
> >> pf: PROCESS_FACTORY
> >> p: PROCESS
> >> retried: BOOLEAN
> >> do
> >> if not retried then
> >> last_error := 0
> >> create Result.make (10)
> >> create pf
> >> p := pf.process_launcher_with_command_line (a_cmd, a_dir)
> >> p.set_hidden (True)
> >> p.set_separate_console (False)
> >> p.redirect_output_to_agent (agent (res: STRING; s: STRING)
> >> do
> >> res.append_string (s)
> >> end (Result, ?)
> >> )
> >> p.launch
> >> p.wait_for_exit
> >> else
> >> last_error := 1
> >> end
> >> rescue
> >> retried := True
> >> retry
> >> end
> >>
> >> Hope this helps,
> >> Jocelyn
> >>
> >> On 9/10/2008 13:51, Daniel Tuser wrote:
> >>
> >>> I would like to use EiffelProcess. Could someone tell me if it is
> >>>
> >> usable
> >>
> >>> with Windows and Linux? And are there simple examples?
> >>>
> >>> Regards,
> >>> Daniel
> >>>
> >>> ------------------------------------
> >>>
> >>> Yahoo! Groups Links
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
>