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.
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