3

我有一个小 perl 脚本,它试图从 git 存储库中提取,然后从 git log 中获取一些东西:

 use Git::Repository;
 my $repo = Git::Repository->new(
         git_dir => $git_path,
 );
 $repo->run('pull') || die $!;
 my @commits = $repo->run(log);
 ...

对于身份验证,我有一个.netrc-file,其中包含我的凭据/home/bla。当脚本从 shell 运行时,这非常有效。现在我尝试将此脚本用于 Web 应用程序:

my $evil_commits = `./list_commits.pl`;

当我这样做时,它会产生以下错误消息:

[Thu Sep 19 12:50:49 2013] [error] [client <>] fatal: Could not read password: No such device or address at ./list_commits.pl line 45

我已经尝试$ENV{HOME}在 CGI 脚本中进行设置,但这无济于事。关于我在这里缺少什么的任何建议?

4

1 回答 1

0

您可以尝试从脚本中打印当前目录。这样,您将能够以使其指向正确文件的方式更改路径。


除此之外,我建议您使用 ssh-keys。在这种情况下,您将不需要任何密码文件。

于 2013-09-19T11:14:05.070 回答