Menu

NppExec run another child process

Ben
2009-04-22
2012-11-14
  • Ben

    Ben - 2009-04-22

    Hi,
    First thanks for nice piece of code!

    Second, is it possible to create several child process OR just kill the last child process(s) and start a new process by an script?

    The reason for choosing a child process is that I want to have output from the process visible (in the Console).

    All I want to achieve is to:
    - run a Python program and see the output in the console (for debugging purpose),
    - next when I want to test the python program again after some eventual changes are applied, can run it just by pressing one button (for example F6 or another shortcut). The last process can be still running or just killed though by the script.

    What I currently do is that I have to kill the process manually before I can start a new child process, but as I mentioned above I want to automate a bit this process and do all steps by only one key press. But I can't make it.

    Here is one of what I have tried so far.

    npp_run taskkill /IM pythonw.exe (or cmd.exe)
    cmd /k C:\MSC.Software\MD_Adams\R4_beta\python\win32\pythonw.exe -u $(FULL_CURRENT_PATH)

    Greatfull if somebody can help.
    Thanks,
    /Behnam

     
    • Ben

      Ben - 2009-04-29

      Np, I've actually moved to Eclipse for a while as the main DE and fortunately one can run as many times just by ONE key-press.

      But what is the benefit of key-press over the shortcut command?

       
    • DV

      DV - 2009-04-23

      Please read this thread:

      http://sourceforge.net/forum/forum.php?thread_id=2371190&forum_id=672146

      I guess, you can send an exit message to Python when NppExec asks for it, this message will finish the current Python process, and the next desired action will be executed at once.

       
    • Ben

      Ben - 2009-04-24

      Hi DV!
      Thanks for the thread. It's the same problem. but I coun't figure out the solution still.

      Note that all I need is to somehow sending the Terminate command in the "NppExec - Warning - Console process is still running" dbox in my running script or CTRL-C

      So the question would be is there any command or shourtcut to Terminate button or CTRL-C? Something link "Npp_termin" would be perfect!

      Thanks in advance!

       
    • DV

      DV - 2009-04-25

      If you mean the child process must be terminated automatically (without NppExec's warning), I have to say it will not be done because it is unsafe. Terminating the process may cause resources leak or something like that, it is not a normal way to finish the process. For example, let's take "cmd.exe" - a normal way to finish it is to type "exit" inside cmd's console. You can start "cmd.exe" inside NppExec, then try to execute another command or script while cmd is running, and NppExec will show its window "NppExec - WARNING - Console process is still running". Now you can type "exit" as 'exit message' in this window and press 'Send' button or just press Enter. The message "exit" will be sent to cmd, and NppExec's command or script you wanted will be started right after the cmd's process will be finished as a result of its "exit" message.
      If the python's process can be finished with "quit();" or something like that, you should use this string as the 'exit message'. Once you type it, you will need just to press Enter next time you see NppExec's warning window.

       
    • Ben

      Ben - 2009-04-27

      OK, let's put it in this way.

      First I have to start my python command such as:

      cmd /c C:\python25\python.exe

      Without "cmd /c" I couldn't manage to show the application GUI. Please try this and try to end the python execution without using CTRL-C. I seem can't communicate to the cmd windows any longer to close it.  If there is a method to do this, then I think I'll be all set.

      All I'd like to achieve is to skip pushing the "Send" or Enter each time I run to debug.

      Side note: you seem already have implemented the Terminate in the dbox even though you think it is "unsafe" (together with showing a text that it is not recommended). I think this is all fine. Now creating a Npp_Terminate would do exactly the same thing or? If the "not recommended" text make it safe, then you can of course have a similar text beside the command in the help (like unsafe, use it on your risk or whatever).

      PS. There are many unsafe objects in the world which are much worse (drugs, guns, power, etc) and people use or abuse them with their insight. Having a terminate command is probably not much more dangerous. :)

       
    • Ben

      Ben - 2009-04-27

      OK, let's put it in this way.

      First I have to start my python command such as:

      cmd /c C:\python25\python.exe

      Without "cmd /c" I couldn't manage to show the application GUI. Please try this and try to end the python execution without using CTRL-C. I seem can't communicate to the cmd windows any longer to close it.  If there is a method to do this, then I think I'll be all set.

      All I'd like to achieve is to skip pushing the "Send" or Enter each time I run to debug.

      Side note: you seem already have implemented the Terminate in the dbox even though you think it is "unsafe" (together with showing a text that it is not recommended). I think this is all fine. Now creating a Npp_Terminate would do exactly the same thing or? If the "not recommended" text make it safe, then you can of course have a similar text beside the command in the help (like unsafe, use it on your risk or whatever).

      PS. There are many unsafe objects in the world which are much worse (drugs, guns, power, etc) and people use or abuse them with their insight. Having a terminate command is probably not much more dangerous. :)

       
    • DV

      DV - 2009-04-28

      If you need Python's console to input some commands, use NPP_RUN to run Python in its own console window.
      If you want to run some Python's program, you can do it directly in NppExec's Console:

      C:\python25\python.exe my_python_program.py

      Both approaches do not need to terminate the Python's process.
      Anyway, NPP_TERMINATE will not be implemented. You can implement such command by yourself, if you want.