- 论坛徽章:
- 0
|
我想在PERL中调用PHP的命令行模式发送邮件,很不幸地这个命令中即含有双引号,也含有单引号。命令如下:
/usr/bin/php -r 'mail("aaa@aaa.com","subject","contact");'
这一行命令在SHELL下直接执行是没有问题的。现在想在PERL中用system()来调用。但会报错。
#!/usr/bin/perl
system("/usr/bin/php -r 'mail("aaa@aaa.com","subject","contact");'");
出错如下:
Bareword found where operator expected at ./a.sh line 2, near ""/usr/bin/php -r 'mail("aaa"
(Missing operator before aaa?)
Array found where operator expected at ./a.sh line 2, at end of line
String found where operator expected at ./a.sh line 2, near "com",""
Bareword found where operator expected at ./a.sh line 2, near "","subject"
(Missing operator before subject?)
String found where operator expected at ./a.sh line 2, near "subject",""
Bareword found where operator expected at ./a.sh line 2, near "","contact"
(Missing operator before contact?)
String found where operator expected at ./a.sh line 2, near "contact");'""
syntax error at ./a.sh line 2, near ""/usr/bin/php -r 'mail("aaa"
Execution of ./a.sh aborted due to compilation errors.
我估计有可能是命令中的引号引起这个问题,查了PERL手册也没找到解决办法,望大家出手相助,谢谢! |
|