Execing Process _ Golang

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

In the previous example we looked at spawning external processes. We do the when we need a external process accessible to running Go process. Sometimes we just want to completely replace the current Go process with another one. To does this we'll use Go ' s implementation of the classic EXEC function

Package Mainimport ("OS"    "os/exec"    "Syscall"Func Main () {binary, Lookerr:= Exec. Lookpath ("ls")    ifLookerr! =Nil {panic (Lookerr)} args:= []string{"ls"," -A","- L","- H"} env:=OS. Environ () Execerr:=Syscall. Exec (binary, args, env)ifExecerr! =Nil {panic (execerr)}}
Total3656drwxr-xr-x -XJK Staff 578B APR1  -: +. DRWXR-xr-x+ -XJK Staff1.0K Mar6  -:xx ..-rw-r--r--@1XJK Staff6.0K Mar -  One: + . Ds_store-rw-r--r--1XJK Staff 838B Mar -  -: -Reading.go-rw-r--r--1XJK Staff 553B Mar -  -: AUrl.go-rw-r--r--1XJK Staff 598B Mar -  -: $Writing.go-rw-r--r--1XJK Staff 402B Mar -  -: atBase64.go-rw-r--r--1XJK Staff 447B Mar to  -: -Commandlineflags.go-rwxr-xr-x1XJK Staff1.7MMar to  -: +commonlineargument-rw-r--r--1XJK Staff 209B Mar to  -: -Commonlineargument.go-rw-r--r--1XJK Staff 261B APR1  -: GenevaEnvironmentvariables.go-rw-r--r--1XJK Staff 303B APR1  -: AExecingprocess.go-rw-r--r--1XJK Staff 298B Mar to  -: theLinefilters.go-rw-r--r--1XJK Staff 384B Mar -  -:GenevaNumber_parsing.go-rw-r--r--1XJK Staff 189B Mar -  -: -Sha.go-rw-r--r--1XJK Staff 720B APR1  -: theSpawningprocess.go-rwxr-xr-x1XJK Staff 243B Mar -  One: -urllib001.py

Summarize:

1: ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.