简体   繁体   English

在 windows 上使用 perl 脚本而不安装 ActivePerl?

[英]Using a perl script on windows without installing ActivePerl?

I'm using Perl as my scripting language of choice under Windows and normally I just install ActivePerl (mostly 5.8 for personal legacy reasons) and be done with it.我在 Windows 下使用 Perl 作为我选择的脚本语言,通常我只安装ActivePerl (出于个人遗留原因,主要是 5.8)并完成它。

I now face the problem that I'd like to use some small scripts on a machine where I do not have any admin rights and therefore cannot install the ActiveState distribution with its installer.我现在面临的问题是,我想在没有任何管理员权限的机器上使用一些小脚本,因此无法使用其安装程序安装 ActiveState 发行版。

What needs to be zipped together from an installed ActiveState Perl to do an xcopy-style installation of Perl on Windows?需要从已安装的 ActiveState Perl 中压缩哪些内容才能在 Windows 上进行 Perl 的 xcopy 式安装? (And which environment variables will then have to be set in a command shell to make it work?) (然后必须在命令 shell 中设置哪些环境变量才能使其工作?)

Strawberry Perl has a portable edition.草莓Perl有便携版。 I'd use that in preference to trying to hack ActivePerl into working without being properly installed.我会使用它而不是尝试在没有正确安装的情况下破解 ActivePerl 工作。

You can install ActivePerl without admin rights by using the *.zip file installer instead of the *.msi.您可以使用 *.zip 文件安装程序而不是 *.msi 来安装没有管理员权限的 ActivePerl。 Download from the ActivePerl 5.26.3 download directory and run the installer.bat file in the root of the extracted tree.ActivePerl 5.26.3 下载目录下载并运行解压树根目录下的installer.bat文件。

PAR::Packer allows you to pack perl along with your scripts and modules it depends on in a standalone executable. PAR::Packer允许您将perl以及它所依赖的脚本和模块打包到一个独立的可执行文件中。 You might want to double-check ActiveState's license terms to make sure this type of distribution is allowed.您可能需要仔细检查 ActiveState 的许可条款,以确保允许这种类型的分发。

Strawberry Perl from David's answer might be the best solution as it officially supports xcopy installation. 大卫回答的草莓 Perl 可能是最好的解决方案,因为它正式支持 xcopy 安装。

However, I have now just tried copying the installation directory C:\Perl of ActiveState and when C:\Perl\bin is added to PATH it seems to execute my script(s) just fine.但是,我现在刚刚尝试复制 ActiveState 的安装目录C:\Perl并且当C:\Perl\bin添加到PATH时,它似乎可以很好地执行我的脚本。

Obviously, you have to run scripts via __> perl file.pl as no file association exists for Windows to know how to call just __> file.pl as it would when using the installed version, but you always have to do that with xcopy-installs.显然,您必须通过__> perl file.pl运行脚本,因为 Windows 不存在文件关联来知道如何调用__> file.pl就像使用已安装版本时一样,但您始终必须使用 xcopy -安装。

I have also inspected the MSI installer from ActiveState (for 5.8) and it only contains files that are installed to TARGETDIR\Perl so I think just copying the Perl directory should also be safe for ActiveState.我还检查了 ActiveState 的 MSI 安装程序(对于 5.8),它只包含安装到TARGETDIR\Perl的文件,所以我认为只复制 Perl 目录对于 ActiveState 也应该是安全的。

Here is the link where you can get portable perl edition.这是您可以获得便携式 perl 版本的链接。 http://strawberryperl.com/releases.html http://strawberryperl.com/releases.html

Here are some Explanatory Notes from the page where you can fine different installation files.以下是页面中的一些解释性说明,您可以在其中调整不同的安装文件。 eg MSI, ZIP etc例如微星、ZIP 等

MSI installer = preferred way, requires admin privileges to install MSI 安装程序 = 首选方式,需要管理员权限才能安装

ZIP edition = admin privileges not required, however you need to run some post-install scripts manually after unzip ZIP 版本 = 不需要管理员权限,但是您需要在解压缩后手动运行一些安装后脚本

PortableZIP edition = suitable for "perl on USB stick" (you can move/rename the perl directory and it will still work) PortableZIP edition = 适用于“USB 棒上的 perl”(您可以移动/重命名 perl 目录,它仍然可以工作)

MSM merge module = for advanced users who want to build their own MSI based on Strawberry Perl MSM 合并模块 = 适合想要基于草莓 Perl 构建自己的 MSI 的高级用户

DDrive edition = (not used since 5.12 series) special edition with fixed install path to d:\strawberry DDrive edition =(自 5.12 系列以来未使用)具有固定安装路径到 d:\strawberry 的特别版

From what I hear, ActivePerl can be tricky to handle this way.. however, I found this at perlmonks:据我所知,ActivePerl 以这种方式处理可能会很棘手。但是,我在 perlmonks 发现了这一点:

http://www.perlmonks.org/?node=Portable%20perl%3A%20usb%20thumbdrive http://www.perlmonks.org/?node=Portable%20perl%3A%20usb%20thumbdrive

In short: Guy wants perl on windows without admin rights, so he makes a usb thumbdrive that does the job.简而言之:Guy 想要 windows 上的 perl 没有管理员权限,所以他制作了一个 usb 拇指驱动器来完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM