Lua and os.execute return - iphone

I am writing a lua script and I have to execute two shell commands that both keep echo-ing information until terminated with ^C.
This means os.execute is useless since it waits for the return code, which never comes, and freezes the entire script. Do you have any idea on how to make this work? A good solution is not to require os.execute to return any value so it will send the command and move on but I think this is not possible. Another is multithreading that I haven't been able to make it work whatsoever.
I also must have the ability to somehow stop both infinite-loops by either using ^C or a lua method. The script is running on iPhone (iOS 5.0.1 / root) using Lua 5.1.4.

os.execute('yourcommand&')
That should run the command in the background and return to your Lua script immediately.
If you want more sophisticated process control, you're probably going to want to write that in native code.

Related

Launch on event with python

here I write my first question as programming beginner starting with python.
I have a small script that executes a loop, which function is to download a list from the server, compare it with other lists and see if something has happened. Usually the answer is NO, but sometimes something happens. When the answer becomes YES, I would like this script at this point to be able to "launch the second program", a similar script that from here takes care of the instructions to handle the specific event signaled while the " main program "continues to interrogate the server and compare the answers (that's the only thing he has to do).
considering that you can run it with two clicks from the desktop specifying only one variable (that comes from the first script), I thought it was easy to "trigger" the execution of a python file in a new window or something like that ...can anybody tell me how I can make it start at the request of the first script avoiding that the first script remains blocked waiting for answers and continues to execute its cycle?

Interfacing with command line applications

I have a command line application, which I want to remotely control with another program I've yet to make. What is the best way to go about this?
In more detail:
I want to be able to read the text output of the application I want to control, and send commands to it from my other app via simple text input. Preferred language: python, c or c++
I tried to use winautogui, but couldn't find a way to implement it for CMD.
I found a python version of expect for windows called wexpect, which does the job.

Changing Code At Runtime While Debugging

I am using Eclipse Kepler Service Release 2 , EPIC 0.5.46 and Strawberry Perl 5 version 18 for perl programming. For debugging I am using Eclipse debugger and PadWalker .
I have an interactive perl program that writes to files based on answers provided by the users to multiple prompts. While debugging , every time i change a single line of code I have to rerun the whole program again and provide inputs to every prompt , which is really time consuming.
Is there a way to make changes to the code in a sub routine , in the middle of debugging session such that the instruction pointer resets itself to the first line of that sub routine. This way i do not have to restart the session to recompile the new code.
Appreciate your inputs and suggestions. Thank You!!!
What you want to do can be done, and I've done it many times in Perl myself. For example, see this.
However although what you describe may work (and is a bit dangerous), the way it is generally done a bit different and safer.
First one has to assume a regular kind of command structure like a command processor, or say a web server.
In a command processor or web server, you read a command (or get a web request), perform an action, then read another command, perform another action and so on. From your description, it sounds like you have such a structure.
In my case, I have each debugger command stored as in Perl file. This is helpful not only for facilitating this task, but also for understanding, testing and changing the code.
Given this kind of program structure, instead of trying to change the program counter, you complete the command and at the level where you are about to read a new command, you make the change and then reload the file which changes the code.
The specific Perl construct to do this is called do. Don't use require or use which will load in a Perl file only if that file or module hasn't been previously loaded. In your situation, you want to reload even if it has been loaded before.
So now how do you get to be able to issue a do command? As you suggest, you could do it through a debugger. Assuming you have this overall program stucture as described above, you put the breakpoint somewhere a common point in the caller which loops over things to process, rather than try to change things in indvidual commands.
And you don't even need a debugger to do this! Many web frameworks like Ruby on Rails, have a "development" mode where they save timestamps on files that implement functionality. If the file has changed they issue the "do" command before running the request.

How to execute an .exe file in Progress OpenEdge

Before I ask anything, let me tell you I have no experience whatsoever on Progress Openedge, but my company runs an application made in it and now I have to make some SOAP calls through it. So I figured, why not call an external script made in whatever language I deem fit?
But I can't even find how to run an external script through OpenEdge when I google for it. There's no examples anywhere, the documentation is long and confusing (for me at least). That brings me to this simple question:
How can I call an external script in Progress OpenEdge?
Try OS-COMMAND.
See Progress Knowledge Base, too.
And a complete description on how to interact with your OS.
I had a similar problem and ended up using this in a Windows application:
OS-COMMAND NO-CONSOLE "program_executed_here".
The lack of a "NO-WAIT" means my progress code waited until the command was finished (which I needed). The NO-CONSOLE keeps Progress from popping up an annoying console window after the OS command finishes running.

Precompiled applescript service?

I have created an automator service for my finder which runs an applescript. I will have to use this service incredibly often. I have noticed that after running the service, there is a very large (about ten second) delay before I receive any popups from the script. This is far too long. I am almost positive this delay comes form automator compiling my script every time it is run....
So, I have a question -- is there a way to pre-compile an applescript, then install that applescript as a finder service? Going through automator was the simplest way I could think of to install my script as a service, but if there is a better way -- particularly one that pre compiles my applescript, that would be great.
I'm not sure if it's a "compiled" issue. I see long delays sometimes too, even with compiled scripts. Automator actions are run by the "automator runner" application and applescripts are run by the "applescript runner" application (unless they're created as stand-alone applications). I notice sometimes that during the first launch that it takes extra time but on subsequent launches it acts faster... maybe because the runner applications are up and running during subsequent runs. So I'm more likely to believe it's something in the runner applications rather than the script itself.
However you can run a "compiled" script if you wish. Just create the script as a separate file. Then in the applescript portion of your automator action use this...
run script file "path:to:script.scpt".
With that being said, you can even create the applescript as an application and then run that from automator...
tell application "MyApplescript" to activate
Maybe one of those solutions will help speed it up for you. If you do achieve a speedup, please let us know.