使用 C Shell 脚本确定 Microsoft Windows 的版本? [英] Determine version of Microsoft Windows using C Shell Script?

查看:25
本文介绍了使用 C Shell 脚本确定 Microsoft Windows 的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里问了一个类似的问题,但那是使用珀尔.现在我的老板告诉我必须使用 C Shell Script (.csh).我是初学者&试图从此处了解事物.所以我创建了这个脚本:

I had asked a similar question here but that was using perl. Now my boss tells me I have to use C Shell Script (.csh). I am a beginner & trying to understand things from here. So I created this script:

set OS_NAME = (Win32::GetOSVersion());
set major = $OS_NAME[1];
set minor = $OS_NAME[2];
set build = $OS_NAME[3];
set id = $OS_NAME[4];
echo $major;
echo $minor;
echo $build;
echo $id;

这给了我输出:

Win32::GetOSVersion
(
)
#blank line

如何让脚本工作?谢谢.

How do I get the script to work? Thank You.

更新:发现一些此处.根据现在不起作用的评论.那么对此有任何更新的答案吗?

UPDATE: Found something here. As per the comment that does not work nowadays. So any updated answer for this?

更新:找到解决方案此处.但是它像 echo 一样打印信息.我如何将这些信息存储在变量中,以便我可以进行一些比较 &做我的工作吗?

UPDATE: Found the Solution here. But its printing the information just like echo does. How do I store that information inside Variables so that I can do some comparison & do my work?

推荐答案

经过一番折腾找到了解决方案:

After a lot of head banging found the solution:

set Ver = `(wmic os get version)`;
echo $Ver;

之前不知道`` 运算符可以将输出捕获到变量.即使是一个相同的答案/评论也会为我节省很多时间.

Did not know earlier that the `` operator can catch the output to a variable. Even a single answer/comment about the same would have saved a lot of my time.

希望有人回复,但尽管获得了 42 次浏览,但没有人回复.非常失望&被社区辜负了.:(

Was hoping for somebody to reply, but despite getting 42 views there was no answer. Extremely disappointed & let down by the community. :(

这篇关于使用 C Shell 脚本确定 Microsoft Windows 的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆