Question neewby

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

Question neewby

Jiri-2
Hello everyone, new on the list and looking forward to get to know more
on Haxe. My first Haxe project ever is using Screenweaver. I want to
build a flash  gui to control the build process we have here. We use
rake and ruby to compile out swf's, but I would like to provide a gui
for it. Becuase some work with windows and some with mac I thought Haxe
would be a good solution.
I am having difficulty running a thread. This thread needs to call a
shell script and I will need to know when it is done.
I tried
<script>
if ( neko.Sys.command("sh test.sh" ) != 0 )
             throw "Failed to called test.sh";
         systools.Dialogs.message("Result","DONE",false);
</script>
But that obvisouly freezes the whole client.

No i am trying to create a thread and that works to, but one thing i can
seem to get going is neko.io.Process and use the output. How does that
work, could someone provide me an example. The script in the example
below is not being executed.
Could I also run rb directly, now I wrapped it inside a sh script?

<script>
var tProces:Process = new neko.Sys.Process("sh test.sh" , []);
#where to direct the output to?
var tOut:Output = tProces.stdout();
</script>

Last question, how can i monitor Lib.println() where does it go to?

Thank you for taking the time reading my questions.

Jiri

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Question neewby

Ian Martins
I'm not sure I understood your questions but maybe this will help.

neko.io.Process.exitCode() blocks until the process completes.  you can
use that to wait until your shell script is done.

neko.io.Process.stdout is a property, not a function, and it gives you
the output of the subprocess, so you can read it (as an input).
so to get a line from a subprocess' stdout, use var str =
subProcess.stdout.readLine();

Jiri wrote:

> Hello everyone, new on the list and looking forward to get to know
> more on Haxe. My first Haxe project ever is using Screenweaver. I want
> to build a flash  gui to control the build process we have here. We
> use rake and ruby to compile out swf's, but I would like to provide a
> gui for it. Becuase some work with windows and some with mac I thought
> Haxe would be a good solution.
> I am having difficulty running a thread. This thread needs to call a
> shell script and I will need to know when it is done.
> I tried
> <script>
> if ( neko.Sys.command("sh test.sh" ) != 0 )
>             throw "Failed to called test.sh";
>         systools.Dialogs.message("Result","DONE",false);
> </script>
> But that obvisouly freezes the whole client.
>
> No i am trying to create a thread and that works to, but one thing i
> can seem to get going is neko.io.Process and use the output. How does
> that work, could someone provide me an example. The script in the
> example below is not being executed.
> Could I also run rb directly, now I wrapped it inside a sh script?
>
> <script>
> var tProces:Process = new neko.Sys.Process("sh test.sh" , []);
> #where to direct the output to?
> var tOut:Output = tProces.stdout();
> </script>
>
> Last question, how can i monitor Lib.println() where does it go to?
>
> Thank you for taking the time reading my questions.
>
> Jiri
>




--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Question neewby

Jiri-2
Thank you Ian,

so if I understood correctly i can block the complete neko VM by calling

neko.io.Process.exitCode(), or does it just block the thread(if I
decided to run it in one) block.


My next question would then be how to find out when the shell script is
done. I can imagine I would use the neko.io.Process.stdout to read the
output or do some kind of pinging?

Is there a way to know or set a callback function when a process is done?

What I want to achieve is call a shell script from neko and then trigger
a function when the script is done.



Thnx

Jiri

Ian Martins wrote:

> I'm not sure I understood your questions but maybe this will help.
>
> neko.io.Process.exitCode() blocks until the process completes.  you can
> use that to wait until your shell script is done.
>
> neko.io.Process.stdout is a property, not a function, and it gives you
> the output of the subprocess, so you can read it (as an input).
> so to get a line from a subprocess' stdout, use var str =
> subProcess.stdout.readLine();
>
> Jiri wrote:
>> Hello everyone, new on the list and looking forward to get to know
>> more on Haxe. My first Haxe project ever is using Screenweaver. I want
>> to build a flash  gui to control the build process we have here. We
>> use rake and ruby to compile out swf's, but I would like to provide a
>> gui for it. Becuase some work with windows and some with mac I thought
>> Haxe would be a good solution.
>> I am having difficulty running a thread. This thread needs to call a
>> shell script and I will need to know when it is done.
>> I tried
>> <script>
>> if ( neko.Sys.command("sh test.sh" ) != 0 )
>>             throw "Failed to called test.sh";
>>         systools.Dialogs.message("Result","DONE",false);
>> </script>
>> But that obvisouly freezes the whole client.
>>
>> No i am trying to create a thread and that works to, but one thing i
>> can seem to get going is neko.io.Process and use the output. How does
>> that work, could someone provide me an example. The script in the
>> example below is not being executed.
>> Could I also run rb directly, now I wrapped it inside a sh script?
>>
>> <script>
>> var tProces:Process = new neko.Sys.Process("sh test.sh" , []);
>> #where to direct the output to?
>> var tOut:Output = tProces.stdout();
>> </script>
>>
>> Last question, how can i monitor Lib.println() where does it go to?
>>
>> Thank you for taking the time reading my questions.
>>
>> Jiri
>>
>
>
>
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Question neewby

Ian Martins
exitCode blocks the thread that calls it until the process it was called
on exits.
so, when the statement after exitCode is executed, the shell script is done.
just put the function call after the call to exitCode, and it'll be
called after the script is done.

---
var p = new neko.io.Process("theScript", []);
p.exitCode(); // wait here until the script completes
callYourFunctionHere();
---

Jiri wrote:

> Thank you Ian,
>
> so if I understood correctly i can block the complete neko VM by calling
>
> neko.io.Process.exitCode(), or does it just block the thread(if I
> decided to run it in one) block.
>
>
> My next question would then be how to find out when the shell script
> is done. I can imagine I would use the neko.io.Process.stdout to read
> the output or do some kind of pinging?
>
> Is there a way to know or set a callback function when a process is done?
>
> What I want to achieve is call a shell script from neko and then
> trigger a function when the script is done.
>
>
>
> Thnx
>
> Jiri
>
> Ian Martins wrote:
>> I'm not sure I understood your questions but maybe this will help.
>>
>> neko.io.Process.exitCode() blocks until the process completes.  you
>> can use that to wait until your shell script is done.
>>
>> neko.io.Process.stdout is a property, not a function, and it gives
>> you the output of the subprocess, so you can read it (as an input).
>> so to get a line from a subprocess' stdout, use var str =
>> subProcess.stdout.readLine();
>>
>> Jiri wrote:
>>> Hello everyone, new on the list and looking forward to get to know
>>> more on Haxe. My first Haxe project ever is using Screenweaver. I
>>> want to build a flash  gui to control the build process we have
>>> here. We use rake and ruby to compile out swf's, but I would like to
>>> provide a gui for it. Becuase some work with windows and some with
>>> mac I thought Haxe would be a good solution.
>>> I am having difficulty running a thread. This thread needs to call a
>>> shell script and I will need to know when it is done.
>>> I tried
>>> <script>
>>> if ( neko.Sys.command("sh test.sh" ) != 0 )
>>>             throw "Failed to called test.sh";
>>>         systools.Dialogs.message("Result","DONE",false);
>>> </script>
>>> But that obvisouly freezes the whole client.
>>>
>>> No i am trying to create a thread and that works to, but one thing i
>>> can seem to get going is neko.io.Process and use the output. How
>>> does that work, could someone provide me an example. The script in
>>> the example below is not being executed.
>>> Could I also run rb directly, now I wrapped it inside a sh script?
>>>
>>> <script>
>>> var tProces:Process = new neko.Sys.Process("sh test.sh" , []);
>>> #where to direct the output to?
>>> var tOut:Output = tProces.stdout();
>>> </script>
>>>
>>> Last question, how can i monitor Lib.println() where does it go to?
>>>
>>> Thank you for taking the time reading my questions.
>>>
>>> Jiri
>>>
>>
>>
>>
>>
>




--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

haxemedia

jmgens
In reply to this post by Jiri-2
hello haxe friends
I would like to add some features  to the chat included in haxemedia
project
i have already done that on haxechat but i don t see this project anywhere
when i try to compile this haxechat with the last version of haxe it
seems that some classes disapears

so i have done some modifications on haxemedia ( an users list ) but i
have seen that function
UserLeave is not called anymore
I am not an expert in haxe neko management to do that presence handling
so a little help will be welcomed
forgive my english

jean-michel

--
haXe - an open source web programming language
http://haxe.org

jeanmichel_gens.vcf (114 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Question neewby

Jiri-2
In reply to this post by Ian Martins
Allright I will try that. Thank you Ian!

Jiri


Ian Martins wrote:

> exitCode blocks the thread that calls it until the process it was called
> on exits.
> so, when the statement after exitCode is executed, the shell script is
> done.
> just put the function call after the call to exitCode, and it'll be
> called after the script is done.
>
> ---
> var p = new neko.io.Process("theScript", []);
> p.exitCode(); // wait here until the script completes
> callYourFunctionHere();
> ---
>
> Jiri wrote:
>> Thank you Ian,
>>
>> so if I understood correctly i can block the complete neko VM by calling
>>
>> neko.io.Process.exitCode(), or does it just block the thread(if I
>> decided to run it in one) block.
>>
>>
>> My next question would then be how to find out when the shell script
>> is done. I can imagine I would use the neko.io.Process.stdout to read
>> the output or do some kind of pinging?
>>
>> Is there a way to know or set a callback function when a process is done?
>>
>> What I want to achieve is call a shell script from neko and then
>> trigger a function when the script is done.
>>
>>
>>
>> Thnx
>>
>> Jiri
>>
>> Ian Martins wrote:
>>> I'm not sure I understood your questions but maybe this will help.
>>>
>>> neko.io.Process.exitCode() blocks until the process completes.  you
>>> can use that to wait until your shell script is done.
>>>
>>> neko.io.Process.stdout is a property, not a function, and it gives
>>> you the output of the subprocess, so you can read it (as an input).
>>> so to get a line from a subprocess' stdout, use var str =
>>> subProcess.stdout.readLine();
>>>
>>> Jiri wrote:
>>>> Hello everyone, new on the list and looking forward to get to know
>>>> more on Haxe. My first Haxe project ever is using Screenweaver. I
>>>> want to build a flash  gui to control the build process we have
>>>> here. We use rake and ruby to compile out swf's, but I would like to
>>>> provide a gui for it. Becuase some work with windows and some with
>>>> mac I thought Haxe would be a good solution.
>>>> I am having difficulty running a thread. This thread needs to call a
>>>> shell script and I will need to know when it is done.
>>>> I tried
>>>> <script>
>>>> if ( neko.Sys.command("sh test.sh" ) != 0 )
>>>>             throw "Failed to called test.sh";
>>>>         systools.Dialogs.message("Result","DONE",false);
>>>> </script>
>>>> But that obvisouly freezes the whole client.
>>>>
>>>> No i am trying to create a thread and that works to, but one thing i
>>>> can seem to get going is neko.io.Process and use the output. How
>>>> does that work, could someone provide me an example. The script in
>>>> the example below is not being executed.
>>>> Could I also run rb directly, now I wrapped it inside a sh script?
>>>>
>>>> <script>
>>>> var tProces:Process = new neko.Sys.Process("sh test.sh" , []);
>>>> #where to direct the output to?
>>>> var tOut:Output = tProces.stdout();
>>>> </script>
>>>>
>>>> Last question, how can i monitor Lib.println() where does it go to?
>>>>
>>>> Thank you for taking the time reading my questions.
>>>>
>>>> Jiri
>>>>
>>>
>>>
>>>
>>>
>>
>
>
>
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Help with neko.io.Process

Jiri-2
In reply to this post by Ian Martins
Why is the shell script not being executed, I tried a zillion
variations, and the cwd is pointing to the dir where the shell is
located? What am I doing wrong??

var path:Path = new neko.io.Path('/Users/{name}/Documents/deploy/');
neko.Sys.setCwd(path.dir);
systools.Dialogs.message("Result","CWD dir: "+neko.Sys.getCwd() ,false);
var p = new neko.io.Process("sh test.sh", []);
p.exitCode();
onCompileDone();

The test.sh is only creating a temp dir, so i know it is working....

#!/bin/sh

mkdir temp

Please some help would be very nice. Also, do I have to hard code the
CWD or is there a function I can call to get the current dir ?

Jiri



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Help with neko.io.Process

Nicolas Cannasse
Jiri a écrit :
> Why is the shell script not being executed, I tried a zillion
> variations, and the cwd is pointing to the dir where the shell is
> located? What am I doing wrong??
>
> var path:Path = new neko.io.Path('/Users/{name}/Documents/deploy/');
> neko.Sys.setCwd(path.dir);
> systools.Dialogs.message("Result","CWD dir: "+neko.Sys.getCwd() ,false);
> var p = new neko.io.Process("sh test.sh", []);

Try maybe :

new neko.io.Process("/bin/sh",["test.sh"])

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Help with neko.io.Process

Jiri-2
Thank you that seemed to work.

Nicolas Cannasse wrote:

> Jiri a écrit :
>> Why is the shell script not being executed, I tried a zillion
>> variations, and the cwd is pointing to the dir where the shell is
>> located? What am I doing wrong??
>>
>> var path:Path = new neko.io.Path('/Users/{name}/Documents/deploy/');
>> neko.Sys.setCwd(path.dir);
>> systools.Dialogs.message("Result","CWD dir: "+neko.Sys.getCwd() ,false);
>> var p = new neko.io.Process("sh test.sh", []);
>
> Try maybe :
>
> new neko.io.Process("/bin/sh",["test.sh"])
>
> Nicolas
>

--
haXe - an open source web programming language
http://haxe.org