Created
January 8, 2021 10:09
-
-
Save vgvgvvv/978252d1d5f4732e79da942157038ca9 to your computer and use it in GitHub Desktop.
Run Android Command By Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"os/exec" | |
) | |
func main() { | |
log.Println("logcat") | |
cmd := exec.Command("logcat") | |
f, err := os.Create("/sdcard/out.txt") | |
if err != nil { | |
panic(err) | |
} | |
defer f.Close() | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
err = cmd.Run() | |
if err != nil { | |
log.Fatal(err) | |
} | |
//fmt.Printf("in all caps: %q\n", out.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment