jackxiao / jslibs

Automatically exported from code.google.com/p/jslibs
0 stars 0 forks source link

Add System() to call shell functions (patch) #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I needed to call shell functions, in order to use jshost as a
general-purpose scripting language.  So, using the crudest sort of
monkey-coding, I managed to hack in a System() function that executes a
shell command asynchronously and returns the exit code, like
system.ShellExecute(), I suppose.

1. This has only been compiled/tested under GNU/Linux (Ubuntu 8.04, x386)

2. I don't know if you even want something this crude in your library.  Or
if 'jsstd' is where it should go.

3. If I get some time, here, I would like to hack in something like
python's popen(), which lets you redirect stdin, stdout and stderr, run it
asynchronously if you want, poll for completion, and works on x86, 64bit,
Windows and Linux (I don't know where I can even SEE a Mac).  I also think
it would be useful to make a uname() to return platform type, info and
version, and maybe a getenv() to return environment variables.

   a. Are you even interested in anything like that?

   b. Would you point me at anywhere (besides your code, and SpiderMonkey
docs) for suggested coding styles?

   c. Are any of these functions already in SpiderMonkey or jshost?  I
didn't see them, and I looked through all the docs, but it's not the same
as knowing the code ...

Original issue reported on code.google.com by Griffin3...@gmail.com on 4 Jun 2008 at 7:20

Attachments:

GoogleCodeExporter commented 9 years ago
Uhm, not a defect, and priority is low. Zero. I forgot to change these before I
submitted.

Glenn

Original comment by Griffin3...@gmail.com on 4 Jun 2008 at 7:22

GoogleCodeExporter commented 9 years ago
Hi, just have a look at the following page: 
http://code.google.com/p/jslibs/wiki/jsio
and tell me what do you think about the CreateProcess function.
http://code.google.com/p/jslibs/source/browse/trunk/src/jsio/static.cpp#475
(and same for the systemInfo global property)

Original comment by sou...@gmail.com on 4 Jun 2008 at 9:03

GoogleCodeExporter commented 9 years ago

Original comment by sou...@gmail.com on 4 Jun 2008 at 9:24

GoogleCodeExporter commented 9 years ago
That looks like exactly what I need ... Thank you!

[Did you write this in the two hours since my request, or did you read my mind 
at
some previous time, by analyzing my jshost usage patterns?]

Original comment by Griffin3...@gmail.com on 5 Jun 2008 at 9:33

GoogleCodeExporter commented 9 years ago
I can read people's mind and my coding rate is very high.
BTW, your patch is fine. And don't hesitate to submit patches if you have other 
good
ideas to extend jslibs.

Original comment by sou...@gmail.com on 5 Jun 2008 at 9:58