PHP exec()没有从bash命令获取输出

时间:2017-08-15 15:27:28

标签: php linux bash

我试图从bash命令中获取输出。 如果我直接在bash中执行some命令,我会看到结果。但不是PHP exec()函数..

   public void CreateEnvelopeWithTwoRecipients()
    {
        string accountID = Init(); //Initialization Code

        byte[] fileBytes = System.IO.File.ReadAllBytes(@"C:\temp\Agreement.pdf");
        var envDef = new EnvelopeDefinition()
        {
            EmailSubject = "My Envelope Subject",
            Status = "sent",
            Documents = new List<Document>()
            {
                new Document()
                {
                    DocumentBase64 = System.Convert.ToBase64String(fileBytes),
                    Name = "Contract",
                    DocumentId = "1"
                }
            },
            Recipients = new Recipients()
            {
                Signers = new List<Signer>() 
                {
                    new Signer()
                    {
                        Email = "janedoe@acme.com",
                        Name = "Jane Doe",
                        RecipientId = "1",
                        RoutingOrder = "1",
                        clientUserId = "10000"
                        Tabs = new Tabs()
                        {
                            SignHereTabs =  new List<SignHere>()
                            {
                                new SignHere()
                                {
                                    DocumentId = "1",
                                    AnchorXOffset = "150",
                                    AnchorXOffset = "5",
                                    AnchorString = "PARTICIPANT SIGNS",
                                    AnchorUnits = "pixels",
                                    Optional = "true"

                                }
                            }
                        }
                    },
                    new Signer()
                    {
                        Email = "johnsmith@acme.com",
                        Name = "john smith",
                        RecipientId = "2",
                        RoutingOrder = "2",
                        Tabs = new Tabs()
                        {
                            SignHereTabs =  new List<SignHere>()
                            {
                                new SignHere()
                                {
                                    DocumentId = "1",
                                    AnchorXOffset = "150",
                                    AnchorXOffset = "5",
                                    AnchorString = "Second PARTICIPANT SIGNS",
                                    AnchorUnits = "pixels",
                                    Optional = "true"
                                }
                            }
                        }
                    }
                }
            }
        };

        EnvelopesApi envelopesApi = new EnvelopesApi();
        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountID, envDef);
    }

此命令尝试使用ffmpeg lib获取视频分辨率。视频路径很好,我三重检查。

谢谢!

编辑:bash中输出的截图

enter image description here

1 个答案:

答案 0 :(得分:2)

尝试使用反斜杠转义正则表达式中的$。由于你用双引号包装所有东西,PHP试图插入$ _的值,这不是一件事。我运行你的代码时收到了一个未定义的变量通知。当我逃离$时,它对我有用。