想以root身份运行bash脚本但是延迟了.怎么能实现这个?
sudo "sleep 3600; command" , or
sudo (sleep 3600; command)
Run Code Online (Sandbox Code Playgroud)
不起作用.
现在我的app.psgi包含(简化):
builder {
enable 'Session', store => 'File'; #default uses Plack::Session::State::Cookie
$app;
};
Run Code Online (Sandbox Code Playgroud)
后来,$app我正在使用:
my $req = Plack::Request->new($env);
my $session = $req->session(); #returns env->{'psgix.session'}
$session->{user} = "name";
Run Code Online (Sandbox Code Playgroud)
它工作正常,例如:
现在,我希望在登录面板中实现"记住我"功能.在这种情况下,不应从浏览器中自动删除sesion-state-cookie.这可以通过使用Plack :: Session :: State :: Cookie中的expires方法来完成.
问题:
如何从我的更改cookie过期(由Session中间件管理)$app.换句话说,如何在这里调用expire方法:
my $req = Plack::Request->new($env);
my $session = $req->session(); #returns env->{'psgix.session'}
$session->{user} = "name"; …Run Code Online (Sandbox Code Playgroud) Plack套件通常使用http://0:port.例如以下内容
plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root=>".");'
Run Code Online (Sandbox Code Playgroud)
版画
HTTP::Server::PSGI: Accepting connections at http://0:5000/
Run Code Online (Sandbox Code Playgroud)
但是,LWP::UserAgent(或一些更深层次的模块)不接受它,例如:
perl -MLWP::UserAgent -E '$u=LWP::UserAgent->new;$res=$u->get("http://0:5000/valid/path");print $res->status_line'
Run Code Online (Sandbox Code Playgroud)
打印:
500 No Host option provided
Run Code Online (Sandbox Code Playgroud)
但是
perl -MLWP::UserAgent -E '$u=LWP::UserAgent->new;$res=$u->get("http://localhost:5000/valid/path");print $res->status_line'
Run Code Online (Sandbox Code Playgroud)
版画
200 OK
Run Code Online (Sandbox Code Playgroud)
问题是:谁错了?
http://0:port有效的,例如LWP是"错误的"有以下内容:
use 5.014;
use warnings;
BEGIN {
use subs qw(int);
sub int {
print STDERR "\tthe int got: $_[0]\n";
my $res = CORE::int($_[0]);
print STDERR "\tCORE::int: $res\n";
return $res;
}
}
my $x;
$x = 1.1 ; say "result of int($x) is: ", int($x);
$x = 6.6 ; say "result of int($x) is: ", int($x);
Run Code Online (Sandbox Code Playgroud)
它打印
the int got: 1.1
CORE::int: 1
result of int(1.1) is: 1
the int got: 6.6
CORE::int: 6
result of int(6.6) is: 6
Run Code Online (Sandbox Code Playgroud)
该int …
在我以前的问题中,我问过如何使用多个模块.得到了一个完美的答案,另一个指向Modern :: Perl模块的东西真的很简单.
经过一点点搜索CPAN后,我找到了另一个名为uni :: perl的模块,这真的很复杂 - 它等同于:
use strict;
use feature qw(say state switch);
no warnings;
use warnings qw(FATAL closed threads internal debugging pack substr malloc
unopened portable prototype inplace io pipe unpack regexp
deprecated exiting glob digit printf utf8 layer
reserved parenthesis taint closure semicolon);
no warnings qw(exec newline);
use utf8;
use open (:utf8 :std);
use mro 'c3';
Run Code Online (Sandbox Code Playgroud)
有人可以解释/评论它是如何工作的吗?
我将整个代码粘贴到几个部分,并将我的问题添加到(with ###)中.
我明白这个问题真的很长.但是,将它分成更小的一个将无济于事,因为整体是关于"uni :: perl"模块.
请帮助我理解有问题的部分.
package uni::perl; …Run Code Online (Sandbox Code Playgroud) 我有一个非常古老的perl系统(大约8-10岁),但是一个大的(100+ pm文件).现在由于某种原因需要"重新现代化"它 - 一步一步.
我想要完成的第一件事就是在每个模块中插入我的pragma:
use MySw::PerlDefs;
Run Code Online (Sandbox Code Playgroud)
什么将包含像Modern :: Perl和/或在这个问题中的东西:如何使用现代perl和utf8默认值"使用My :: defaults"?
QST1:推荐的方式是什么?
添加use MySw::PerlDefs;就会得到
package MySw::SomePackage; use MySw::PerlDefs; #my new "pragma"
或者在包声明后添加包含在BEGIN块中的PerlDefs?例如:
package MySw::SomePackage;
BEGIN {use MySw::PerlDefs;} #my new "pragma" in the BEGIN block
问题:
Ps:我理解比在编译时出现的BEGIN,但在上面的上下文中 - 它并不比"简单使用"更好?
我正在尝试将我当前的Apache/Modperl站点转移到Starman,并且需要使用不同的处理程序构建app.psgi以用于不同的文件扩展名.像Apache一样的东西:
<LocationMatch "(\.m|\.mh|\/)$">
SetHandler perl-script
PerlHandler MyApp::Mhandler
</LocationMatch>
<LocationMatch "(\.p|\.ph)$">
SetHandler perl-script
PerlHandler MyApp::Phandler
</LocationMatch>
Run Code Online (Sandbox Code Playgroud)
我现在有:
#app for handle .m and .mh
my $Mapp = Some::PSGI->handler( sub {
...
});
#app for handling .p and .ph
my $Papp = SomeOther::PSGI->handler( sub {
...
});
Run Code Online (Sandbox Code Playgroud)
但如何使用建设者?
builder {
#any extension what is not .m .mh .p .ph - handle as static
#but, only when the request have any extension
enable "Plack::Middleware::Static",
path => __what here__, ???
root => "/my/doc/root";
#and what …Run Code Online (Sandbox Code Playgroud) 这是我的情景:

所以,
https://server1/MyPerlApphttps://server1/MyPerlApp到http://server2:5000问题1:这可能吗?(问,因为我不太了解Apache,这不是一个简单的:
ProxyPass /MyPerlApp http://server2:5000/
Run Code Online (Sandbox Code Playgroud)
因为我需要在server1上验证用户身份,并ProxyPass在验证时设置Only.由于Apache非常灵活,我认为上面的答案是肯定的(但确认和细节非常受欢迎) - 所以这是我的主要具体问题:
perl服务器2上的应用程序的简单方法?例如,使用Apache 为每个查询mod_rewrite附加一个user=username参数,perl应用应该读取的一些HTTP标头吗?我正在寻找如何避免我的starman/perl应用程序中的身份验证例程,因为:
已经有类似的问题,但是:
寻找一些bash专家的解释.下一个之间的确切区别是什么
command1 | command2
Run Code Online (Sandbox Code Playgroud)
例如,经典管道,其中command1的stdout被重定向到command2的stdin,例如
和
command1 > >(command2)
Run Code Online (Sandbox Code Playgroud)
结果(和bash动作)是一样的......
至少我得到了相同的
find . -print0 | xargs -0 -n1 -I% echo =%=
Run Code Online (Sandbox Code Playgroud)
和
find . -print0 > >(xargs -0 -n1 -I% echo =%=)
Run Code Online (Sandbox Code Playgroud)
是> >(command)唯一更长的说法|吗?或者不是,我错过了什么?
有这样的线:
xxAyayyBwedCdweDmdwCkDwedBAwe
;;;; cleaner example
__A__B__C__D__C_D_BA_
Run Code Online (Sandbox Code Playgroud)
想要替换ABCD成PQRT例如得到
__P__Q__R__T__R_T_QP_
Run Code Online (Sandbox Code Playgroud)
例如,下一个bash或perl的等价 tr
tr '[ABCD]' '[PQRT]' <<<"$string"
Run Code Online (Sandbox Code Playgroud)
如何在"vim"中执行此操作?(VIM - Vi IMproved 7.4(2013年8月10日,2014年5月9日编译12:12:40))