Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,3 +1,4 @@
|
|||
BEGIN {
|
||||
system("ls")
|
||||
system("ls") # Unix
|
||||
#system("dir") # DOS/MS-Windows
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
-- system --
|
||||
-- the simplest way --
|
||||
-- system spawns a new shell so I/O redirection is possible --
|
||||
|
||||
system( "dir /w c:\temp\ " ) -- Microsoft --
|
||||
|
||||
system( "/bin/ls -l /tmp" ) -- Linux BSD OSX --
|
||||
|
||||
----
|
||||
|
||||
-- system_exec() --
|
||||
-- system_exec does not spawn a new shell --
|
||||
-- ( like bash or cmd.exe ) --
|
||||
|
||||
integer exit_code = 0
|
||||
sequence ls_command = ""
|
||||
|
||||
ifdef UNIX or LINUX or OSX then
|
||||
ls_command = "/bin/ls -l "
|
||||
elsifdef WINDOWS then
|
||||
ls_command = "dir /w "
|
||||
end ifdef
|
||||
|
||||
exit_code = system_exec( ls_command )
|
||||
|
||||
if exit_code = -1 then
|
||||
puts( STDERR, " could not execute " & ls_command & "\n" )
|
||||
elsif exit_code = 0 then
|
||||
puts( STDERR, ls_command & " succeeded\n")
|
||||
else
|
||||
printf( STDERR, "command %s failed with code %d\n", ls_command, exit_code)
|
||||
end if
|
||||
|
|
@ -1,13 +1,16 @@
|
|||
package main
|
||||
import "fmt"
|
||||
import "os/exec"
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cmd := exec.Command("ls", "-l")
|
||||
output, err := cmd.Output()
|
||||
if (err != nil) {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Print(string(output))
|
||||
cmd := exec.Command("ls", "-l")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
(exec "ls")
|
||||
Loading…
Add table
Add a link
Reference in a new issue