Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having a strange issue with running scripts (perl and ruby failing) from incoming mail locally delivered by procmail.
The system is CentOS 5.5 with postfix as my mailer, then a .forward set up to send email on to procmail. The .procmailrc and scripts are identical to a working setup on an Ubuntu server.
And then the failure in the log upon receiving email:
Code:
procmail: Executing "/home/web/perltest.pl"
/home/web/perltest.pl: line 3: syntax error near unexpected token `"touch /home/web/touchedfile"'
/home/web/perltest.pl: line 3: `system("touch /home/web/touchedfile");'
The line endings are all UNIX. The script runs fine from the command line.
The whole setup works fine if I pipe to procmail directly from the command line, but when it's invoked as part of the local delivery process, the #! line seems to be ignored in the script.
I can get the perl script to run if I explicitly execute perl in the pipe, like so:
You need to give the full path to the command touch in your perl script:
No, it's not an issue of the Perl script itself. If you look at the error message, the Perl executable isn't even being called. Instead, the sh (bash) parser is choking on the perl code.
Normally, something like this is the result of line ending problems (DOS, usually) so where the #! line isn't parsed correctly by the shell and the sh interpreter assumes that the file is a valid shell script.
As I mentioned, the line endings are correct. The file is executed properly if I put "|perl /home/web/perltest.pl" in the procmail. For some reason, though, the #! line is being ignored.
(Also worth noting that lots of other scripts I have don't work either when executed from this procmail pipe. They always fail to parse on the first line of the script, whether it's perl or ruby)
Last edited by ChrisInAlpharetta; 04-21-2011 at 11:33 AM.
FYI I've tried to run the script through procmail and got the same error, until I used the full path to the touch command.
So I guess it's worth trying it...
FYI I've tried to run the script through procmail and got the same error, until I used the full path to the touch command.
So I guess it's worth trying it...
Nah. Didn't work. I also tried getting rid of calling any external executables by using only Perl's API:
Code:
my $file = '/home/web/touchedfile';
open(FILE, ">$file") or die "Couldn't open file";
print FILE "ARGS: ", join(', ', @ARGV), "\n";
close FILE;
This didn't work either:
Code:
procmail: Executing "/home/web/perltest.pl"
/home/web/perltest.pl: line 3: my: command not found
/home/web/perltest.pl: line 4: syntax error near unexpected token `FILE,'
/home/web/perltest.pl: line 4: `open(FILE, ">$file") or die "Couldn't open file";'
The fact that the "my" wasn't even parsed is a sure sign that the Perl interpreter isn't engaged.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.