Re: OS Command display in a magic window


Avgerinos
 

Hi Frederik and thank you for your reply

I 'm interested in magic showing the OS window itself inside it own MDI than catching the output of the OS command.
I was hooping there would be something already in our community.

It sure must be possible through some DotNet script.
In google it seems there are such solutions, like:   https://www.codeproject.com/Articles/335909/Embedding-a-Console-in-a-C-Application

I will try making converting it to a magic-snippet, even if my knowledge is quite minimal at this.

Best regards
Avgerinos


On 5/6/2020 12:18 μ.μ., Frederik Soete wrote:
Hi, Avgerinos,

If the script terminates quickly, you can capture its output via command line redirection to a file. Some people use such to list a directory, e.g:

dir > a.txt 2>&1
If you replace 'dir' by your script invocation (the script location preceded by the location of your python interpreter), normal output STDOUT would be redirected to 'a.txt', while '2>&1' ensures error output STDERR is also appended to the same file. You could then load the file to a variable, and display it in a Magic window.

Those are old dos/magic basics.

Similar things would be possible in DotNet, without the need for an intermediate file. I have once written such code, but do not have it accessible right now.

Advanced DotNet would perhaps allow to capture the continuous output of a longer process while it is still running. I am not certain it is possible in Magic, because I have not tried.

What exactly do you have in mind, and what runtime (duration) does your script have?

I hope this helps.

Bye,

Frederik Soete


Op vr 5 jun. 2020 10:51 schreef Avgerinos <mento@...>:
Hi magicians

Is there any way to Invoke an OS command (in my case execute a python
script) with the output displayed inside a magic window instead of the
classic DOS-window?
(XPA versions 3-4)

Best regards and thanks in advance
Avgerinos





Join main@magicu-l.groups.io to automatically receive all group messages.