Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

what are these modules in perl script

Posted on 2016-07-31
4
Medium Priority
?
142 Views
Last Modified: 2016-08-01
I have written a script to send me an email when a new post in a forum comes out. however, when I run this script I got the folloing error:

[jyu@jenkins-test ~]$ crontab -l
40 */2 * * * /home/jyu/script/mit.pl
[jyu@jenkins-test ~]$ /home/jyu/script/mit.pl
/home/jyu/script/mit.pl: line 4: use: command not found
/home/jyu/script/mit.pl: line 5: use: command not found
/home/jyu/script/mit.pl: line 6: use: command not found
/home/jyu/script/mit.pl: line 7: use: command not found
/home/jyu/script/mit.pl: line 8: use: command not found
/home/jyu/script/mit.pl: line 9: use: command not found
/home/jyu/script/mit.pl: line 12: use: command not found
/home/jyu/script/mit.pl: line 14: my: command not found
/home/jyu/script/mit.pl: line 16: my: command not found
/home/jyu/script/mit.pl: line 18: my: command not found
/home/jyu/script/mit.pl: line 20: my: command not found
/home/jyu/script/mit.pl: line 22: my: command not found
/home/jyu/script/mit.pl: line 24: my: command not found
/home/jyu/script/mit.pl: line 26: syntax error near unexpected token `"xiaoyaogu",'
/home/jyu/script/mit.pl: line 26: `main( "xiaoyaogu", $encoding, $selector );'
[jyu@jenkins-test ~]$ perl /home/jyu/script/mit.pl
[jyu@jenkins-test ~]$ which perl
/usr/bin/perl
[jyu@jenkins-test ~]$ cd script/
[jyu@jenkins-test script]$ ls -alth
total 12K
drwxr-xr-x 2 jyu developers 4.0K Jul 31 20:25 .
drwxr-xr-x 9 jyu developers 4.0K Jul 31 20:25 ..
-rw-r--r-- 1 jyu developers    0 Jul 31 20:21 new
-rwxr-xr-x 1 jyu developers 2.2K Jul 31 19:50 mit.pl
[jyu@jenkins-test script]$ vi mit.pl
[jyu@jenkins-test script]$ sudo su
root@jenkins-test:/home/jyu/script$ perl -MCPAN -e shell
mit.pl.txt
0
Comment
Question by:Jason Yu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Assisted Solution

by:Mazdajai
Mazdajai earned 1000 total points
ID: 41736778
You get the error first time because the system don't which interpreter to use.

#!/usr/bin/env perl 

Open in new window


It works the second time because you pass it to run perl directly. Add the following to the first line of the script -

[jyu@jenkins-test ~]$ perl /home/jyu/script/mit.pl

Open in new window

0
 

Author Comment

by:Jason Yu
ID: 41736806
Hi, Mazdajai:

I added your line to my script and it doesn't give me errors anymore, but I still didn't receive any emails about the new posts. How could I test if the email was blocked by the firewall?

The source code is in the attachment of the last post.

thanks.
0
 
LVL 80

Accepted Solution

by:
arnold earned 1000 total points
ID: 41736976
The first line should be a complete path to perl
which perl
#!/usr/bin/perl

Make sure the commands you use inside I.e. Sendmail is a full path /usr/sbin/sendmail
Cron defaults to a limited path /bin:/usr/bin such that sendmail will not be found if referenced.

Cron based script should always use explicit and completes paths to command and directories/files that the script needs/uses.
0
 

Author Comment

by:Jason Yu
ID: 41738315
got it, thank you very much, it's working now.
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question