加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

.net – 单声道shell执行

发布时间:2020-12-15 20:56:41 所属栏目:安全 来源:网络整理
导读:我使用在Centos 6.0 64位上运行Apache的Mono 2.11.1构建来运行名为Provisionning的Web服务,该服务与Asterisk交互. 我需要调用并执行一个 shell命令来转换音频文件,称为Sox.问题是我收到此错误消息: System.ServiceModel.FaultException: System.ComponentMo
我使用在Centos 6.0 64位上运行Apache的Mono 2.11.1构建来运行名为Provisionning的Web服务,该服务与Asterisk交互.
我需要调用并执行一个 shell命令来转换音频文件,称为Sox.问题是我收到此错误消息:

System.ServiceModel.FaultException: System.ComponentModel.Win32Exception: ApplicationName='sox.sh',CommandLine='/var/lib/asterisk/sounds/4/chimes.wav /var/lib/asterisk/sounds/4/chimes_sox.wav',CurrentDirectory='/var/www/html/vms/bin/',Native error= Cannot find the specified file
 at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo,System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
 at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo,System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
 at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in <filename unknown>:0
 at Provisionning.VMSWS.ShellExec (System.String cmd,System.String path,System.String parms,System.Int32& exit_code) [0x00000] in <filename unknown>:0
 at Provisionning.VMSWS.SoxConvert (System.String fileName,System.String targetDir) [0x00000] in <filename unknown>:0
 at Provisionning.VMSWS.UploadFile (System.String username,System.String password,System.Byte[] f,System.String fileName) [0x00000] in <filename unknown>:0
 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
 at System.Reflection.MonoMethod.Invoke (System.Object obj,BindingFlags invokeAttr,System.Reflection.Binder binder,System.Object[] parameters,System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

如果我直接指定/usr/bin上的sox命令,没有任何参数,我从sox应用程序获得默认的“no-arguments specified”消息.
如果我用两个参数指定sox命令,我会得到相同的错误消息我粘贴.
为了传递和减少一些可能性,我创建了一个位于webservice的bin目录中的shell脚本,该目录使用一些参数执行sox命令.手动执行sox.sh脚本,一切正常.从webservice的代码执行sox.sh脚本,我得到了相同的错误指定.

shell执行过程方法如下:

protected String ShellExec(string cmd,string path,string parms,out int exit_code)
    {
        System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(cmd,parms);
        psi.RedirectStandardOutput = true;
        psi.UseShellExecute = false;
        psi.WorkingDirectory = path;

        System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
        string tool_output = p.StandardOutput.ReadToEnd();
        p.WaitForExit();

        exit_code = p.ExitCode;
        return tool_output;
    }

这很简单

任何线索?我真的无法理解缺少的东西….

TIA

SCharrua

解决方法

尝试将完整路径传递给sox.sh.

还要确保将#!/ bin / sh作为shell脚本的第一行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读