- 論壇徽章:
- 0
|
我想在PERL中調(diào)用PHP的命令行模式發(fā)送郵件,很不幸地這個命令中即含有雙引號,也含有單引號。命令如下:
/usr/bin/php -r 'mail("aaa@aaa.com","subject","contact");'
這一行命令在SHELL下直接執(zhí)行是沒有問題的,F(xiàn)在想在PERL中用system()來調(diào)用。但會報錯。
#!/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手冊也沒找到解決辦法,望大家出手相助,謝謝! |
|