上一篇,找到了查看未读邮件个数方法,需要用go来执行doveadm命令,于是考虑使用go exec包

但是代码写好了之后一直报错:exit status 64,意思是选项错误,但是明明所有选项都是ok的,那么只可能是我使用go exec包的方式不对,最后各种尝试,发现go exec中,命令的所有参数都需要分开填写才行。

 package main

 import (
"bytes"
"fmt"
"log"
"os/exec"
"strings"
) func main() {
cmd := exec.Command("doveadm", "mailbox", "status", "-u", "test@example.com", "-t", "unseen" ,"INBOX")
// cmd := exec.Command("doveadm", "mailbox status -u test@example.com -t unseen INBOX") // 这种写法是不对的
cmd.Stdin = strings.NewReader("some input")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
fmt.Printf("in all caps: %q\n", out.String())
}

go exec:exit status 64的更多相关文章

  1. Docker Quickstart Terminal: exit status 255 解决办法

    原文地址:https://www.jianshu.com/p/061f1ae69937 初识docker,还有先拿Windows 7 尝试下,官方提供了docker toolbox,下载后一键安装,桌 ...

  2. powershell 设置环境变量 -- go 单元测试 exit status 3221225781

    执行单元测试时出错 go test -run TestImage 错误提示如下: exit status 3221225781 这个错误的意思是需要加载对应的库文件找不到,加载对应的库文件就习. 但是 ...

  3. jenkins Exec exit status not zero. Status [-1]

    jenkins是使用ssh连接服务器后,如果使用grep获取进程并kill时,会jenkins Exec exit status not zero. Status [-1],解决办法:在获取进程时,使 ...

  4. 交叉编译:cannot find /lib/libc.so.6 collect2: ld returned 1 exit status

    1.有时候明明指定了交叉编译的动态库搜索路径,但有些库提示还是搜索不到,而且提示的搜索路径有点奇怪,不是指定的路径,比如: /opt/mips-4.4/bin/../lib/gcc/mips-linu ...

  5. 词云:解决pip install wordcloud安装过程中报错“error: command 'x86_64-linux-gnu-gcc' failed with exit status 1”问题

    外部环境:ubuntu16.04, 64bits, 全局环境python2.7 在虚拟环境(python3.5)中执行 pip install wordcloud 时安装失败,报错: error: c ...

  6. pip安装模块时:error: command 'gcc' failed with exit status 1

    用安装python模块出现error: command 'gcc' failed with exit status 1 问题: gcc编译缺少模块 解决方法: yum install gcc libf ...

  7. gcc/g++ 编译时出现:“对’xxxx’未定义的引用,collect2: error: ld returned 1 exit status” 的错误

    出现的问题: 在使用 make 编译实现一个程序时,出现了下面的错误.查看程序源文件所在的目录时发现程序已经完成了编译,并生成了 list_repo.o 的文件,说明是在程序链接生成可执行文件时发生了 ...

  8. command 'x86_64-linux-gnu-gcc' failed with exit status 1错误及解决方案

    Ubuntu16.04安装Scrapy(pip install Scrapy)时提示错误如下: Failed building wheel for cryptography Running setup ...

  9. error: command 'cc' failed with exit status 1

    报错: Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/ ...

随机推荐

  1. clear session on close of browser jsp

    关闭浏览器销毁session <%@ Page Language="C#" AutoEventWireup="true" CodeBehind=" ...

  2. 推荐系统 BPR 算法求解过程

    数据假设: 每个用户之间的偏好行为相互独立 同一用户对不同物品的偏序相互独立 则优化问题为极大化如下目标: [Reference] 1.论文翻译:BPR:面向隐偏好数据的贝叶斯个性化排序学习模型 2. ...

  3. C++ map,set内部数据结构

    1)Set是一种关联容器,它用于存储数据,并且能从一个数据集合中取出数据.它的每个元素的值必须唯一,而且系统会根据该值来自动将数据排序.每个元素的值不能直接被改变.[重点]内部结构采用红黑树的平衡二叉 ...

  4. The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Entitlement "com.apple.frontboard.debugapplications" required to launch applications for debugging").

    最近工程遇到了这个, The request was denied by service delegate (SBMainWorkspace) for reason: Security (" ...

  5. 【struts2】值栈(后篇)

    在值栈(前篇)我们学习了值栈的基本知识,接下来,来看看在程序中具体如何使用值栈. 1 ActionContext的基本使用 1.1 如何获取? 要获取ActionContext有两个基本的方法,如果在 ...

  6. SQL plan directives

    SQL plan directives SQL plan directives含有优化器产生优化的执行计划时需要的附加信息和指令. 在sql执行时,如果cardinality估计有错误,数据库就会创建 ...

  7. mysql_install_db 运行结果

    # /usr/local/mysql/scripts/mysql_install_db \ > --defaults-file=/etc/my.cnf \ > --basedir=/usr ...

  8. Proxy源代码分析——谈谈如何学习Linux网络编程

    Linux是一个可靠性非常高的操作系统,但是所有用过Linux的朋友都会感觉到, Linux和Windows这样的"傻瓜"操作系统(这里丝毫没有贬低Windows的意思,相反这应该 ...

  9. python标准库介绍——34 commands 模块详解

    ==commands 模块== (只用于 Unix) ``commands`` 模块包含一些用于执行外部命令的函数. [Example 3-7 #eg-3-7] 展示了这个模块. ====Exampl ...

  10. 要想有什么样的成就就要有什么样的眼光-SNF快速开发平台

    1.普通人的圈子,谈论的是闲事,赚的是 工资,想的是明天. 2.生意人的圈子,谈论的是项目,赚的是 利润,想的是下一年. 3.事业人的圈子,谈论的是机会,赚的是 财富,想到的是未来和保障. 4.智慧人 ...