« 20 Years Monkeybread … | Home | MBS Xojo Plugins, ver… »

Tip of the day: Shell Execute as one Let statement

You can create a shell, run a command and get the result all in a Let statement or a custom function:

Let ( [

// new Shell

shell = MBS( "Shell.New" );

// run command with parameters

r = MBS( "Shell.Execute"; shell; "/bin/ls"; "/");

// wait for a result up to 5 seconds

r = MBS( "Shell.Wait"; shell; 5);

// read output

error = MBS( "Shell.ReadErrorText"; shell; "UTF-8");

output = MBS( "Shell.ReadOutputText"; shell; "UTF-8")

// free shell

r = MBS("Shell.Release"; shell)

]

 

; output & error ) 

This may be handy to keep this in mind when you need to run a command line tool next time.

PS: We used Command-Option-C shortcut in data viewer to copy formula with styles.

07 11 19 - 10:55