Execute a system command: Difference between revisions

m
(Updated with more modern example)
m (→‎{{header|Wren}}: Minor tidy)
(5 intermediate revisions by 2 users not shown)
Line 690:
 
=={{header|FutureBasic}}==
FB 7.0.23+
Classic FB using Pascal strings
<syntaxhighlight lang="futurebasic">
print unix(@"ls -A")
</syntaxhighlight>
Classic FB using Pascal strings
<syntaxhighlight>
local fn DoUnixCommand( cmd as str255 )
dim as str255 s
 
open "Unix", 2, cmd
Line 780 ⟶ 784:
{{output}}
<pre>
2023
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
Line 802 ⟶ 806:
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2
2 3 4 5 6 7 8 6 _� _�77 8 9 10 11 12 3 4 5 6 7 8 9
9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16
16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23
Line 816 ⟶ 820:
29 30 31 26 27 28 29 30 24 25 26 27 28 29 30
31
</pre>
 
Line 2,233 ⟶ 2,238:
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to do it for us.
 
<syntaxhighlight lang="ecmascriptwren">/* run_system_commandExecute_a_system_command.wren */
class Command {
foreign static exec(name, param) // the code for this is provided by Go
Line 2,244 ⟶ 2,249:
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/* run_system_commandExecute_a_system_command.go*/
package main
 
Line 2,275 ⟶ 2,280:
func main() {
vm := wren.NewVM()
fileName := "run_system_commandExecute_a_system_command.wren"
methodMap := wren.MethodMap{"static exec(_,_)": execCommand}
classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)}
9,482

edits