Hello all. First timer here. I’m finishing my degree in web and software development this April, and just landed a new job. They use Xojo here and I’m still learning all of the syntax.
My question is how would I execute more than one shell script at a time? The logical choices to me would be
sh.Execute(partOne + partTwo)
or
sh.Execute(partOne &/&& partTwo)
or
sh.Execute(partOne) + (partTwo)
or
sh.Execute(partOne) & /&& (partTwo)
but none of these work. Is it possible to execute multiple shell commands?
Do you mean two scripts concurrently, or successively?
If you’d like to run them concurrently, the easiest route within Xojo would be more than one Shell object.
If you’re trying to run two successive shell commands you would join them as any normal string of commands with a semicolon.
It looks like you’re bringing in syntax from another language. You may wish to review the Xojo manual to learn what is legal and what is not within the Xojo language.
Thanks @Tim Parnell - I’ll take a look.
You use the same syntax as the OS’ primary shell for doing the task.
For one after the other:
Windows using the ampersand
the1stCmd /arg1 /arg2 & the2ndCmd /arg1 /arg2
Mac and Linux using the semicolon
the1stCmd /arg1 /arg2 ; the2ndCmd /arg1 /arg2
This will run the1stCmd to completion and THEN run the2ndCmd
For simultaneous execution, use multiple shells as Tim P suggests, setting the shells’ mode to 1 or 2 and looping to wait for a response from either.
Dim theShell1, theShell2 As Shell
theShell1.Mode = 1
theShell2.Mode = 1
theShell1.Execute the1stCmd
theShell2.Execute the2ndCmd
Do
theShell1.Poll
theShell2.Poll
Loop Until Not theShell1.IsRunning And Not theShell2.IsRunning
// handle ErrorCodes and output