如何在与我所在服务器不同的服务器上运行 perl 脚本(通过 BAT 文件)?

发布于 2025-01-03 05:06:06 字数 1266 浏览 0 评论 0原文

在 Windows 服务器上,我有很多 Perl 脚本将数据插入 sqlserver 数据库。它们通过启动 .bat 文件的 sql 代理作业来调用

一切都共存于一台机器 \\oldserver

公司政策的更改要求我拆分系统,以便数据库位于 \\dbserver 上,而 perl 解释器、脚本和支持所有文件都位于 \\appserver 上

为了让我的基于 \\dbserver 的 sql 代理在 \\appserver 上触发 .bat 文件,以便每个 bat 文件都像实际启动一样运行,我需要做什么\\应用程序服务器? (即使用安装在 \\appserver 上的 perl,可以访问 \\appserver Windows 环境设置,如 PERL5LIB 等)?


每个 BAT 文件看起来都像:

@echo off
d:
cd project\foo\scripts\myscript.pl

每个 perl 脚本看起来像:(

#!/perl/bin
use warnings;
use inHouseLibrary; # via PERL5LIB Env variable on \\\appserver
#[snip]

my $incoming = <path to local folder>;
my $archive  = <path to some other local folder>;

my $config;
$config = do $config_file or die;

foreach my $file ( <files in local folder>){
   #do database-related stuff involving the contents of the file
   File::Copy->move($file, $archive . $file);
}

我知道 违反 DRY 原则。这只是我现在必须承担的债务)


如果相关的话:

  • \\dbserver 有 SqlServer 9.0 (2005)
  • \\appserver 有 activestate perl v5.10.1 MSWin32-x86-multithread
  • 两台机器都有windows server 2008 R2 Standard

On a windows server, I have a lot of perl scripts that insert data into a sqlserver database. They get invoked via sql agent jobs that launch .bat files

Everything co-exists on the one machine \\oldserver

Changes in company policy require me to split my system up so the database is on \\dbserver and the perl interpreter, scripts, and supporting files all live on \\appserver

What do I have to do in order to have my \\dbserver-based sql agent fire off .bat files on \\appserver so each bat file runs as if it were actually started on \\appserver? (ie. using perl installed on \\appserver, has access to \\appserver windows environment settings like PERL5LIB, etc)?


Each BAT file looks something like:

@echo off
d:
cd project\foo\scripts\myscript.pl

Each perl script looks something like:

#!/perl/bin
use warnings;
use inHouseLibrary; # via PERL5LIB Env variable on \\\appserver
#[snip]

my $incoming = <path to local folder>;
my $archive  = <path to some other local folder>;

my $config;
$config = do $config_file or die;

foreach my $file ( <files in local folder>){
   #do database-related stuff involving the contents of the file
   File::Copy->move($file, $archive . $file);
}

(I'm aware of the DRY Principle violation. That's just debt I have to carry right now)


In case it's relevant:

  • \\dbserver has SqlServer 9.0 (2005)
  • \\appserver has activestate perl v5.10.1 MSWin32-x86-multithread
  • Both machines have windows server 2008 R2 Standard

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

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

发布评论

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

评论(1

沉默的熊 2025-01-10 05:06:06

这可以使用 Windows Remote Shell 或 Windows Powershell 来完成,也可以使用 SSH。

使用 SSH,语法为:

    ssh login@hostname '<command>'

Windows PowerShell 教程位于:

http:// technet.microsoft.com/en-us/magazine/ff700227.aspx

sysinternals 中还包含一个名为“PsExec”的实用程序,您可能会发现它很有用,位于此处:

http://technet.microsoft.com/en-us/sysinternals/bb897553

This can be done using Windows Remote Shell or Windows Powershell, or you could use SSH.

With SSH, the syntax would be:

    ssh login@hostname '<command>'

The windows PowerShell tutorial is here:

http://technet.microsoft.com/en-us/magazine/ff700227.aspx

There is also a utility included in sysinternals called 'PsExec' that you might find useful, located here:

http://technet.microsoft.com/en-us/sysinternals/bb897553

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