doucheng5705 2012-12-17 15:25
浏览 54

Php / Perl:无法将带有“ ”的电子邮件的Html正文传递给perl

I have a Perl script that i's called by a Php function.

During the call i need to pass as arguments Header, Subject, Body.

But as we know Body can contain "new line" char for example:

Hello Mr x,

this is just a test

Normally we have two new line here.

So when i call the script using system() function :

system("perl /var/www/cgi-bin/daemon.pl $Header $Subject $body", $Res);

The body content will have just

Hello Mr x,

The result that i'am looking for is to have the possibility to pass the new line to perl and recieve the message exactly as is written.

  • 写回答

1条回答 默认 最新

  • dougaxing8673 2012-12-20 09:35
    关注

    Thank you for your help,

    In my solution i used escapeshellarg() in my Php file and in the perl side i found HTML::Entities

    with this i can encode and decode my agreement :

    Here is my code :

    Php file:

    $Header = escapeshellarg($Header);
    $Subject = escapeshellarg($Subject);
    $Body = escapeshellarg($Body);
    
    system("perl /var/www/cgi-bin/daemon.pl $Header $Subject $Body", $Res);
    

    Perl Script :

    #!/user/bin/suidperl -U
    use HTML::Entities;
    
    # The $Header , $Subject and $Body args are well received
    # to pass this args to an other perl script i use encode_entities() function
    
    encode_entities($Header);
    encode_entities($Subject);
    encode_entities($Body);
    

    We can said that HTML::Entities is the same of escapeshellarg.php in PHP

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算