博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
.NET/Rotor源码研究1补遗 - 解决无法检测操作系统版本的错误
阅读量:4190 次
发布时间:2019-05-26

本文共 1760 字,大约阅读时间需要 5 分钟。

最近不少朋友反映在编译Rotor
的时候出现无法检测操作系统版本的错误,具体现象为执行env.bat
的时候报错:
 

Could not get platform OS version

 
 
出现该错误的原因是env.bat
会调用env.core.pl
设置环境,而env.core.pl
在检测操作系统版本的时候会使用到ver
命令的输出结果:

            if (Windows()) {

                            # The output of ver looks like:

                            #

                            # Microsoft Windows XP [Version 5.1.2600]

                            #

                            # (including the empty line before)

 

                            $platform_os_version = `ver`;

                            # we keep the first two fields of the version number

                            if (! ($platform_os_version =~ s//nMicrosoft.*/[Version +([0-9]+/.[0-9]+)/..*/]/$1/g)) {

                                            $platform_os_version = "";

                            }
 

                            if ($platform_os_version =~ /^5/..*/) {

                                            $platform_os_version = "5.1";

                            }
            } else {

                            $platform_os_version = `uname -r`;

                            # we keep all fields of the version number

                            if (! ($platform_os_version =~ s/^[^0-9]*([0-9.]+).*$/$1/s)) {

                                            $platform_os_version = "";

                            }
            }
           

            chomp ($platform_os);

            chomp ($platform_os_version);

            if (! $platform_os_version ) {

                            CorFail ("Could not get platform OS version");

            }
 
 

可以看到env.core.pl使用正则表达式s//nMicrosoft.*/[Version +([0-9]+/.[0-9]+)/..*/]/$1/g来分析Ver的输出结果。如果操作系统为非中文版本或者安装了界面包的情况下,ver命令便有可能输出中文结果,导致脚本出错。虽然可以通过修改系统Locale的方式解决,不过更简单的解决方法显然是直接修改脚本,把$platform_version固定为某个值,比如5.1,修改后代码如下:

            if (Windows()) {

                            # assume 5.1 version because the original code cannot parse the output of ver command correctly in non-English OS

                            $platform_os_version = "5.1";

            } else {

                            $platform_os_version = `uname -r`;

                            # we keep all fields of the version number

                            if (! ($platform_os_version =~ s/^[^0-9]*([0-9.]+).*$/$1/s)) {

                                            $platform_os_version = "";

                            }
            }
           

            chomp ($platform_os);

            chomp ($platform_os_version);

            if (! $platform_os_version ) {

                            CorFail ("Could not get platform OS version");

            }
 
 

这里有一个已经修改好的 (放在我的Windows Live Skydrive账户里面),有需要的朋友可以点击下载,然后覆盖SSCLI20目录下的env.core.pl即可。

 

作者:      张羿(ATField)

Blog:     
               
转载请注明出处

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1836028

你可能感兴趣的文章
Linux-网络运维基础
查看>>
Linux网络运维-SSH
查看>>
Linux网络运维 -- 配置DHCP服务器
查看>>
Android开发问题记录
查看>>
Verilog编程网站学习——门电路、组合电路、时序电路
查看>>
android——学生信息显示和添加
查看>>
Android——ImageSwitcher轮流显示动画
查看>>
Android——利用手机端的文件存储和SQLite实现一个拍照图片管理系统
查看>>
图像调优1:清晰度相关参数MTF,SFR,MTF50,MTF50P 以及TVL的概念以及换算说明
查看>>
图像调优3: CCM参数的标定
查看>>
ctags在verilog代码浏览中的应用
查看>>
NeoVintageous 在sublime中的使用
查看>>
用ncverilog跑仿真时,如何去除对特定路径的timing检查
查看>>
在ncverilog仿真条件设置中+nospecify ,+notimingcheck 和 +delay_mode_zero之间有什么区别
查看>>
linux下nerdtree安装方法
查看>>
最长回文子串(Go,LeetCode)
查看>>
windows下TortoiseGit安装和使用的图文教程
查看>>
基于Jquery的(可视区域,向上滚动向下滚动两种)图片懒加载
查看>>
原生JS的(可视区域,向上滚动向下滚动两种)图片懒加载
查看>>
使用VMware搭建Hadoop集群虚拟网络配置
查看>>