适用于多服务器管理员的便携式脚本语言?

发布于 2024-08-18 18:12:33 字数 1238 浏览 3 评论 0原文

请注意:如portableapps.com 中的“可移植”,而不是传统意义上可在多种架构或操作系统上使用的语言。无论是谁创造了“便携式”一词的这种用法,都应该受到严厉打击。 :)

我是一名 DBA 和系统管理员,主要负责运行 SQL Server 的 Windows 计算机。我正在寻找一种适用于 Windows 的编程/脚本语言,不需要管理员访问权限或安装程序,除了将其展开到文件夹中之外不需要安装过程。我的目的是拥有一种可以标准化的自动化语言。

到目前为止,我一直在使用批处理文件和 Unix shell 的组合,使用 UnxUtils 中的 sh.exe但这远非完美的解决方案。

我评估了一些选项,它们都至少有一个或另一个严重缺点。我对开源或双重许可证有强烈的偏好,但我更感兴趣的是找到合适的工具而不是其他任何东西。对依赖 Cygwin 或 Java 的任何东西不感兴趣,但目前我对需要 .NET 的东西没问题。

要求:

  • 可管理的占用空间(1-100 个文件,安装后小于 30 MB)
  • 在 Windows XP 和 Server (2003+) 上运行
  • 无安装程序(exe、msi)
  • 不依赖 JVM 或 Cygwin 安装
  • 可与外部一起使用管道、进程和文件
  • 支持 MS SQL Server 或 ODBC 连接

奖励点:

  • 开源
  • FFI,用于调用本机 DLL 中的函数
  • GUI 支持(本机或 gtk、wx、fltk 等)
  • Linux、AIX、和/或 OS X 支持
  • 动态、面向对象和/或功能、解释或字节码编译;交互式开发
  • 能够将脚本打包或编译为可执行文件

到目前为止我已经尝试过:

  • Ruby:磁盘上 148 MB,23000 个文件
  • Portable Python:磁盘上 54 MB,2800 个文件
  • Strawberry Perl:磁盘上 123 MB ,3600 个文件
  • REBOL:很好,除了闭源代码并且免费版本中没有 MSSQL 或 ODBC
  • Squeak Smalltalk:很好,除了对脚本的支持很差

Please Note: Portable as in portableapps.com, not in the traditional sense of a language that can be used on multiple architectures or operating systems. Whoever coined this usage of the word portable should be whacked. :)

I'm a DBA and sysadmin, mostly for Windows machines running SQL Server. I'm looking for a programming/scripting language for Windows that doesn't require Admin access or an installer, needing no install process other than expanding it into a folder. My intent is to have a language for automation around which I can standardize.

Up to this point, I've been using a combination of batch files and Unix shell, using sh.exe from UnxUtils but it's far from a perfect solution.

I've evaluated a handful of options, all of them have at least one serious shortcoming or another. I have a strong preference for something open source or dual license, but I'm more interested in finding the right tool than anything else. Not interested that anything that relies on Cygwin or Java, but at this point I'd be fine with something that needs .NET.

Requirements:

  • Manageable footprint (1-100 files, under 30 MB installed)
  • Run on Windows XP and Server (2003+)
  • No installer (exe, msi)
  • No reliance on a JVM or Cygwin install
  • Works with external pipes, processes, and files
  • Support for MS SQL Server or ODBC connections

Bonus Points:

  • Open Source
  • FFI for calling functions in native DLLs
  • GUI support (native or gtk, wx, fltk, etc)
  • Linux, AIX, and/or OS X support
  • Dynamic, object oriented and/or functional, interpreted or bytecode compiled; interactive development
  • Able to package or compile scripts into executables

So far I've tried:

  • Ruby: 148 MB on disk, 23000 files
  • Portable Python: 54 MB on disk, 2800 files
  • Strawberry Perl: 123 MB on disk, 3600 files
  • REBOL: Great, except closed source and no MSSQL or ODBC in free version
  • Squeak Smalltalk: Great, except poor support for scripting

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

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

发布评论

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

评论(7

爱你不解释 2024-08-25 18:12:33

我强烈建议你尝试 Lua。关于您的要求:

  • 占用空间小(56 个源文件,编译后不到 150K)
  • 随处运行(仅使用 ANSI C)
  • 无需安装程序;你从源代码编译(还有一个我没有探索过的 “包含电池”包
  • 不需要 JVM并可与任何 ANSI C 编译器配合使用,因此您可以使用 Visual Studio 进行编译,而不是 Cygwin
  • 可与外部进程和文件配合使用,但仅限于 ANSI C 支持的范围。如果提供了 POSIX popen,则支持还有

你的加分点:

  • 开源(MIT 许可证)
  • FFI to C 的构思和执行都非常出色——不像 Tcl 那么简单,但与 C 的集成比 Python 或 Ruby 更强大。
  • GUI 支持是混合的,但曾经有过对 wx 小部件的良好绑定,但我不知道它是否已被
  • 支持
  • 语言/编译器功能:
    • 动态
    • 功能性
    • 基于原型的对象和通过元方法进行继承(您将希望在下面的书中看到示例
    • 西方最快的字节码编译器
    • 交互式读取-评估-打印循环;动态加载新代码
  • 能够 将脚本打包成可执行文件;或者使用 Luiz de Figueiredo 的 srlua,或者我可以向您发送一个 120 行 Lua 脚本,该脚本将 Lua 源代码转换为 .c 文件,您可以将其链接到您的应用程序和解释器中以生成可执行文件

I urge you to try Lua. Regarding your requirements:

  • Tiny footprint (56 source files, under 150K compiled)
  • Runs everywhere (uses only ANSI C)
  • No installer needed; you compile from source (there's also a "batteries included" package that I haven't explored
  • Doesn't need JVM and works with any ANSI C compiler, so you can compile with Visual Studio, not Cygwin
  • Works with external processes and files but only to the extent supported by ANSI C. If POSIX popen is provided then that is supported also.

And your bonus points:

  • Open source (MIT license)
  • FFI to C is brilliantly conceived and executed—not quite as simple as Tcl but loads more powerful. Much better integration with C than Python or Ruby.
  • GUI support is mixed but there are good bindings for wx widgets. QT support was there at one time but I don't know if it has been maintained.
  • Linux is supported
  • Language/compiler features:
    • Dynamic
    • Functional
    • Prototype-based objects and inheritance through metamethods (you'll want to see examples in the book below
    • Fastest bytecode compiler in the West
    • Interactive read-eval-print loop; load new code dynamically
  • Able to package scripts into executables; either use Luiz de Figueiredo's srlua, or I can send you a 120-line Lua script that converts Lua source to a .c file that you link in with your app and the interpreter to make an executable.

Additional bonus points:

╰◇生如夏花灿烂 2024-08-25 18:12:33

有几个 Python 选项可能适合您的需求:

  • 第一个是 IronPython, 可以是无需安装程序即可运行,并且可以很好地与 .net API 配合使用。这使您可以访问具有 .net API 或 COM 类型库的任何内容,您可以为其构建 PIA。正是出于这个原因,我使用 at 作为脚本编写机制 - 它可以放入系统内的目录中,并且不需要显式安装。.

    您必须有一个适当的 .Net 运行时已安装,但 .Net 2.0 是随 SQL Server 2005 一起安装的。可以通过 ADO.net 访问 SQL Server,并且使用 Winforms 构建 GUI 相当简单。

  • 第二个是Portable Python,它被设计为通过USB密钥运行。虽然我看到你已经尝试过,但你可以详细说明一下缺点是什么。如果基本安装中没有某些内容,您可以随时考虑构建包含它的自定义版本。 TkInter(至少)是捆绑的。

    您还可以使用 Py2EXE 生成独立的 python 应用程序,并删除所有多余的垃圾。这将为您提供大约 10 个左右的文件(取决于 DLL 的数量),这些文件可以从单个目录(可能在 USB 密钥上)运行。

在 Unix-oid 操作系统上运行本地 python 安装非常简单,所以这几乎是理所当然的。此外,Python 随大多数 Linux 发行版一起提供,并且可以从大多数(如果不是全部)传统 UNIX 供应商那里作为“贡献软件”获得。 IIRC 它也与 MacOS 捆绑在一起。

There are a couple of options for Python that might fit your bill:

  • The first is IronPython, which can be run without an installer and will play nicely with .net APIs. This gives you access to anything with a .net API or a COM typelib that you could build a PIA for. I've used at as a scripting mechanism for precisely this reason - it could be dropped into a directory within the system and did not need to be explicitly installed..

    You will have to have an appropriate .Net runtime installed, but .Net 2.0 is installed with SQL Server 2005. SQL Server can be accessed through ADO.net and building GUIs with Winforms is fairly straightforward.

  • The second is Portable Python which is designed to be run off a USB key. Although I see you've already tried it, you might elaborate on what the shortcomings were. If something isn't available in the basic install you could always look into building a custom version with it included. TkInter (at least) is bundled.

    You can also use Py2EXE to generate standalone python applications with all superfluous junk stripped out. This will give you about 10 files or so (depending on the number of DLLs) that can be run from a single directory, possibly on a USB key.

Running local python installs on Unix-oid OS's is pretty straightforward, so that's pretty much a no brainer. Also, python comes with most linux distros and is available as 'contributed software' from most if not all trad unix vendors. IIRC it's also bundled with MacOS.

笔落惊风雨 2024-08-25 18:12:33

Tclkit 是一个单文件、独立的 Tcl/Tk 系统。我的mac版本大约是3.8兆。您可以获得几乎任何现代操作系统的版本。我随身携带一个拇指驱动器,里面有 Mac、Windows 和 Linux 二进制文件,这样我就可以在任何平台上运行我的脚本。无需安装,只需将一个文件复制到任何您想要的位置即可。

原始规范中唯一缺少的是开箱即​​用的 MS SQL Server / ODBC 支持。我知道人们使用 tcl 来实现这一点,但我认为你必须添加一个额外的库或其他东西。有关详细信息,请参阅 MS SQL Server 上的 Tcl'ers wiki 条目

Tclkit is a single-file, self-contained Tcl/Tk system. The mac version I have is about 3.8 megs. You can get a version for just about any modern OS. I carry around a thumb drive that has mac, windows and linux binaries so I can run my scripts on any platform. No install is required, just copy one file wherever you want.

The only thing it's missing from your original spec is MS SQL Server / ODBC support out of the box. I know people use tcl for that but I think you'll have to add an extra library or something. See the Tcl'ers wiki entry on MS SQL Server for more information.

恋你朝朝暮暮 2024-08-25 18:12:33

对于 tcl 来说,除了 Tclkit 之外,freewrap 是另一个小型便携式、独立的 tcl 解释器。

只需将 freewrap 可执行文件重命名为其他名称即可将其转换为独立解释器。将其重命名回 freewrap 会将其转换为脚本包装器。

此外,免费包装的应用程序包含 tcl 解释器。在紧急情况下,您可以尝试将应用程序作为 zip 文件打开,并编辑/替换其中包含的 tcl 代码(只需记住先复制一份)。当我在没有开发工具的客户站点但需要排除某些问题时,这多次帮助我解决问题。我只是复制了我部署的应用程序之一和 presto - 即时开发环境!

For tcl, apart from Tclkit, freewrap is another small portable, self-contained interpreter for tcl.

Just rename the freewrap executable to something else will convert it to a stand-alone interpreter. Renaming it back to freewrap will convert it to a script wrapper.

Also, freewrapped apps contain a tcl interpreter. In dire emergencies you can try opening the app as a zip file and edit/replace the tcl code contained within (just remember to make a copy first). This has saved me several times when I'm at a client site without development tools but need to troubleshoot something. I just make a copy of one of my deployed app and presto - instant development environment!

稍尽春風 2024-08-25 18:12:33

查看维基百科详尽的便携式软件列表
维基百科上有 Tiny C 编译器这里,还有它自己的主页此处

通过引用维基百科的功能列表来总结一下:

  • 小 - 可以在任何地方编译和执行 C 代码,例如在救援磁盘上(x86 TCC 可执行文件大约 100KB,包括 C 预处理器、C 编译器、汇编器和链接器)。
  • 快速 - tcc 生成优化的 x86 代码。没有字节码开销。它的编译、汇编和链接速度大约是 GCC 的 9 倍。
  • 任何C动态库都可以直接使用。 TCC 正朝着完全符合 ISOC99 的方向迈进。 TCC当然可以自己编译。
  • 包括可选的内存和绑定检查器。绑定检查代码可以与标准代码自由混合。
  • 直接编译并执行C源代码。无需链接或组装。包含完整的 C 预处理器和类似 GNU 的汇编器。
  • 支持 C 脚本:只需在 C 源代码的第一行添加“#!/usr/local/bin/tcc -run”,然后直接从命令行执行它。
  • 借助 libtcc,您可以使用 TCC 作为动态代码生成的后端。
  • 很少有依赖性。它包括自己的手写词法分析器,并使用递归下降解析器实现。因此,构建 TCC 需要很少的其他库。
  • 其 LGPL 许可证允许任何人使用、修改和/或重新分发该软件,并且可用于开发开源或专有软件。

希望这会有所帮助并且有用,
此致,
汤姆.

Looking at wikipedia's exhaustive list of portable software
There's Tiny C compiler, again on Wikipedia here, and its own homepage here.

To summarize by quoting from wikipedia's list of features:

  • Small - can compile and execute C code everywhere, for example on rescue disks (about 100KB for x86 TCC executable, including C preprocessor, C compiler, assembler and linker).
  • Fast - tcc generates optimized x86 code. No byte code overhead. It compiles, assembles and links about 9 times faster than GCC.
  • Any C dynamic library can be used directly. TCC is heading towards full ISOC99 compliance. TCC can of course compile itself.
  • Includes an optional memory and bound checker. Bound checked code can be mixed freely with standard code.
  • Compile and execute C source directly. No linking or assembly necessary. Full C preprocessor and GNU-like assembler included.
  • C script is supported: just add '#!/usr/local/bin/tcc -run' at the first line of your C source, and execute it directly from the command line.
  • With libtcc, you can use TCC as a backend for dynamic code generation.
  • Few dependencies. It includes its own hand-written lexer, and it is implemented using a recursive descent parser. Thus, building TCC requires few other libraries.
  • Its LGPL license permits anyone to use, modify, and/or redistribute the software, and it can be used to develop either open source or proprietary software.

Hope this helps and would be of use,
Best regards,
Tom.

季末如歌 2024-08-25 18:12:33

每个现代的 Windows 版本都预装了 VBScript 和 JScript。它们不能满足您的所有功能(我想到的是编译为可执行文件),但它们在安装大小方面确实具有无与伦比的优势:很难击败0

Every somewhat modern Windows version comes pre-installed with both VBScript and JScript. The doesn't meet all your features (compile to an executable comes to mind), but they certainly have an unbeatable advantage with the installation size: it's hard to beat 0.

萌无敌 2024-08-25 18:12:33

除了Lua建议之外,还有Idle。它基本上是 Lua 5.1 的超集,语言(和库)和实现都基于 Lua。它最初是为了成为一个更完整的 Windows 脚本解决方案而创建的:因为 Lua 主要用于嵌入,所以它有一个相当小的标准库,并且通常期望嵌入应用程序为 Lua 提供丰富的库。

这对于嵌入式语言来说是有意义的,因为毕竟 Adob​​e Lightroom、Nginx 和 World of Warcraft 之间没有太多共同的功能,因此您无法将任何内容放入标准中。图书馆。但对于一种更通用的操作系统脚本语言,人们需要一个稍大的库。因此,Idle 在其标准库中捆绑了几个 Lua 第三方库(有时很难在 Windows 上运行)。

Idle 标准库在 Lua 上添加的一些功能包括紧密的 Win32 集成、SQLite3 支持、网络支持、PEG 解析器生成器和存档支持。

此外,Idle 支持将 Perl 和 C 代码嵌入到您的 Idle 程序中。

In addition to the Lua suggestion, there is also Idle. It is basically a superset of Lua 5.1, with both the language (and libraries) and the implementation based on Lua. It was originally created to be a more complete scripting solution for Windows: because Lua is primarly intended for embedding, it has a rather small standard library and it is usually expected that the embedding application provides a rich library to Lua.

This makes sense for an embedded language, because, after all, there isn't much common functionality between, say Adobe Lightroom, Nginx and World of Warcraft, so there simply is nothing you can put in a standard library. But for a more general purpose OS scripting language, one would want a slightly larger library. Thus, Idle bundles a couple of libraries that are third-party (and sometimes hard to get to work on Windows) in Lua in its standard library.

Some of the things that the Idle standard library adds over Lua are tight Win32 integration, SQLite3 support, networking support, a PEG parser generator and archive support.

Also, Idle has support for embedding Perl and C code into your Idle programs.

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