在 Shell 中调用 Perl 代码

在 Perl 中调用 Shell 代码,比较容易。但在 Shell 中调用 Perl 的样例不多。今天再次遇到类似的脚本,帖过来保存:

cat > ${encoder} <<'EOF'
use URI::Escape;
my $msg = "";
my @lines = <STDIN>;

my $msg = uri_escape("@lines");
print $msg . "\n";

exit 0;
EOF

function encode()
{
echo -n "$@" | perl ${encoder}
}

note=Nagios
smsto=$1

可谓经典!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>