5

Centos 6.064ビットでApacheを実行しているMono2.11.1ビルドを使用して、Asteriskと対話するProvisionningという名前のWebサービスを実行します。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アプリケーションからデフォルトの「引数が指定されていません」というメッセージが表示されます。両方の引数を指定してsoxコマンドを指定すると、貼り付けたのと同じエラーメッセージが表示されます。いくつかの可能性を渡し、削減するために、いくつかの引数を指定してsoxコマンドを実行するシェルスクリプトをWebサービスのbinディレクトリに作成しました。sox.shスクリプトを手動で実行すると、すべて問題ありません。Webサービスのコードからsox.shスクリプトを実行すると、指定されたものと同じエラーが発生します。

シェル実行プロセスの方法は次のとおりです。

     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

4

1 に答える 1

2

フルパスをsox.shに渡してみてください。

また#!/bin/sh、シェルスクリプトの最初の行にあることを確認してください。

于 2012-06-25T07:48:52.837 に答える