cleartool 在命令提示符和 C# 应用程序中的行为不同

发布于 2024-10-13 02:31:00 字数 1963 浏览 3 评论 0原文

我正在尝试从 C# 应用程序中获取特定目录中的视图私有列表。
我正在使用下面的函数来进行该调用:

ClearCommand = "ls -r -view_only" 

并且

directory = @"E:\VobName\sampleDir". 

它返回:

cleartool: Error: Pathname is not within a VOB: "E:\VobName\Sampledir"

如果我在 E:\VobName\sampleDir 中的 Windows 命令提示符中执行相同的命令,则它可以正常工作。
知道为什么它的运行方式会出现这种不一致吗?


这是相关代码:

    private String RunCommand(String clearCommand, String directory)
    {
        String retVal = String.Empty;

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "cleartool";
        startInfo.Arguments = clearCommand;
        startInfo.UseShellExecute = false;
        startInfo.CreateNoWindow = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.RedirectStandardError = true;
        startInfo.WorkingDirectory = directory;

        try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process process = Process.Start(startInfo))
            {
                //exeProcess.WaitForExit();

                // Read in all the text from the process with the StreamReader.
                using (StreamReader reader = process.StandardOutput)
                {
                    retVal = reader.ReadToEnd();
                }

                if (String.IsNullOrEmpty(retVal))
                {
                    // Read in all the text from the process with the StreamReader.
                    using (StreamReader reader = process.StandardError)
                    {
                        retVal = reader.ReadToEnd();
                    }
                }
            }
        }
        catch
        {
            Debug.Assert(false, "Error sending command");
        }

        return retVal;
    }

I am attempting to get the list of view privates in a particular directory from within a C# application.
I am using the function below to make that call with:

ClearCommand = "ls -r -view_only" 

and

directory = @"E:\VobName\sampleDir". 

It returns:

cleartool: Error: Pathname is not within a VOB: "E:\VobName\Sampledir"

If I do the same command in the windows command prompt from within E:\VobName\sampleDir, it works fine.
Any idea as to why there would be this inconsistency in the way it runs?


Here is the relevant code:

    private String RunCommand(String clearCommand, String directory)
    {
        String retVal = String.Empty;

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "cleartool";
        startInfo.Arguments = clearCommand;
        startInfo.UseShellExecute = false;
        startInfo.CreateNoWindow = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.RedirectStandardError = true;
        startInfo.WorkingDirectory = directory;

        try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process process = Process.Start(startInfo))
            {
                //exeProcess.WaitForExit();

                // Read in all the text from the process with the StreamReader.
                using (StreamReader reader = process.StandardOutput)
                {
                    retVal = reader.ReadToEnd();
                }

                if (String.IsNullOrEmpty(retVal))
                {
                    // Read in all the text from the process with the StreamReader.
                    using (StreamReader reader = process.StandardError)
                    {
                        retVal = reader.ReadToEnd();
                    }
                }
            }
        }
        catch
        {
            Debug.Assert(false, "Error sending command");
        }

        return retVal;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

维持三分热 2024-10-20 02:31:00
E:\VobName\Sampledir

是分配给路径的驱动器号。请参阅 Windows 命令 <强>subst
您是否尝试过视图的实际完整路径?

(snapshot view)
C:\path\to\myView\VobName\Sampledir

或者:

(dynamic view)
M:\myView\VobName\Sampledir
E:\VobName\Sampledir

is a drive letter assign to a path. See the Windows command subst.
Did you try with the actual full path of the views?

(snapshot view)
C:\path\to\myView\VobName\Sampledir

or:

(dynamic view)
M:\myView\VobName\Sampledir
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文