Ejemplo n.º 1
0
        public List<ApacheInfo> getApacheInfo()
        {
            List<ApacheInfo> retList = new List<ApacheInfo>();
            List<string> pathList = Util.getPath(SSHExec);
            Util.AddIfUnique<string>(pathList, "/sbin");
            Util.AddIfUnique<string>(pathList, "/usr/sbin");
            Util.AddIfUnique<string>(pathList, "/usr/local/sbin");
            Util.AddIfUnique<string>(pathList, "/usr/local/apache/bin");
            Util.AddIfUnique<string>(pathList, "/usr/local/apache/sbin");
            Util.AddIfUnique<string>(pathList, "/usr/local/apache2/bin");
            Util.AddIfUnique<string>(pathList, "/usr/local/apache2/sbin");
            Util.AddIfUnique<string>(pathList, "/usr/local/httpd/bin");
            Util.AddIfUnique<string>(pathList, "/usr/local/httpd/sbin");

            foreach (string pathComp in pathList)
            {
                ApacheInfo thisInfo = new ApacheInfo { Path = pathComp, BinaryName = "httpd" };
                string cmdOutput = SSHExec.RunCommand(thisInfo.FullBinaryPath + " -v || echo ERROR");
                string[] lines = cmdOutput.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                if ((lines.Length >= 2) && (lines[lines.Length - 1] != "ERROR"))
                {
                    string[] versComps = lines[0].Split(new char[] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries);
                    if (versComps.Length == 2)
                    {
                        thisInfo.Version = versComps[1].Trim();
                        retList.Add(thisInfo);
                    }
                }
            }

            return retList;
        }
Ejemplo n.º 2
0
        public IEnumerable<ApacheInfo> getApacheInfo()
        {
            var pathList = Util.GetPath(CommandRunner);
            pathList.AddIfUnique("/sbin");
            pathList.AddIfUnique("/usr/sbin");
            pathList.AddIfUnique("/usr/local/sbin");
            pathList.AddIfUnique("/usr/local/apache/bin");
            pathList.AddIfUnique("/usr/local/apache/sbin");
            pathList.AddIfUnique("/usr/local/apache2/bin");
            pathList.AddIfUnique("/usr/local/apache2/sbin");
            pathList.AddIfUnique("/usr/local/httpd/bin");
            pathList.AddIfUnique("/usr/local/httpd/sbin");

            var allApacheInfo = new List<ApacheInfo>();
            foreach (var pathComp in pathList)
            {
                var apacheInfo = new ApacheInfo { Path = pathComp, BinaryName = "httpd" };
                var commandText = String.Format("{0} -v || echo ERROR", apacheInfo.FullBinaryPath);
                var commandResultLines = CommandRunner.ExecuteCommand(commandText).SplitStringByDefaultNewLine();
                if (commandResultLines.Count() >= 2 && commandResultLines.Last() != "ERROR")
                {
                    var versComps = commandResultLines.First().Split(new [] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries);
                    if (versComps.Length == 2)
                    {
                        apacheInfo.Version = versComps.Last().Trim();
                        allApacheInfo.Add(apacheInfo);
                    }
                }
            }

            return allApacheInfo;
        }
Ejemplo n.º 3
0
        public IEnumerable <ApacheInfo> getApacheInfo()
        {
            var pathList = Util.GetPath(CommandRunner);

            pathList.AddIfUnique("/sbin");
            pathList.AddIfUnique("/usr/sbin");
            pathList.AddIfUnique("/usr/local/sbin");
            pathList.AddIfUnique("/usr/local/apache/bin");
            pathList.AddIfUnique("/usr/local/apache/sbin");
            pathList.AddIfUnique("/usr/local/apache2/bin");
            pathList.AddIfUnique("/usr/local/apache2/sbin");
            pathList.AddIfUnique("/usr/local/httpd/bin");
            pathList.AddIfUnique("/usr/local/httpd/sbin");

            var allApacheInfo = new List <ApacheInfo>();

            foreach (var pathComp in pathList)
            {
                var apacheInfo = new ApacheInfo {
                    Path = pathComp, BinaryName = "httpd"
                };
                var commandText        = String.Format("{0} -v || echo ERROR", apacheInfo.FullBinaryPath);
                var commandResultLines = CommandRunner.ExecuteCommand(commandText).SplitStringByDefaultNewLine();
                if (commandResultLines.Count() >= 2 && commandResultLines.Last() != "ERROR")
                {
                    var versComps = commandResultLines.First().Split(new [] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries);
                    if (versComps.Length == 2)
                    {
                        apacheInfo.Version = versComps.Last().Trim();
                        allApacheInfo.Add(apacheInfo);
                    }
                }
            }

            return(allApacheInfo);
        }