Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Automating Perl Script

Posted on 2011-10-04
5
Medium Priority
?
252 Views
Last Modified: 2012-06-27
Hi,

I want to automate a  Perl script to run daily. Right now I am executing it from the command line as

uniserver:/usr/qa/Scripts/files> ./test.pl  filename

where test.pl is the script and the filename is the file it has to process.(like input file)


but when automating how can I call the script with the filename.

I tried it wrap it up in another script as:

#!/usr/bin/perl

do '/usr/qa/Scripts/files> ./test.pl  filename'      

and call the above script in Cron  but it is not working.

0
Comment
Question by:new_perl_user
5 Comments
 
LVL 5

Expert Comment

by:magento
ID: 36910680
why cant u hard code the variable inside the script..

instead of $1 ..use this my $filename=filename
0
 

Author Comment

by:new_perl_user
ID: 36910721
i DID IT JUST NOW AND WAS ABOUT TO REPLY.

0
 
LVL 23

Accepted Solution

by:
nemws1 earned 2000 total points
ID: 36910805
If you have a script in 'cron' that depends on a file in a local directory, you can do one of 2 things, either 'cd' to the directory first in your crontab and then "&&" the script you want to run (this is also what you want to do if your script opens a file for output and you want it in the same directory):
#min hour day.of.month month day.of.week command
30 3 * * * cd /usr/qa/Scripts/files && ./test.pl filename

Open in new window

Or just give the full path to both the script and the filename:
#min hour day.of.month month day.of.week command
30 3 * * * /usr/qa/Scripts/files/test.pl /usr/qa/Scripts/files/filename

Open in new window

0
 

Author Comment

by:new_perl_user
ID: 36911985

I tried earlier the second one but it did not work. will try the first option and will update.
0
 
LVL 9

Expert Comment

by:parparov
ID: 36913874
Did the cron job fire? Did the script start?

If the cron job fired and script started but failed, or script proved unstartable root would get a mail about the problem.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans
Suggested Courses

564 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