I'm working on a script that will run as a nightly cron job. My perl
skills are not as strong as I would like and I'm hoping someone out
there can help.
The first task is to check if the previous script finished and if not,
sleep 'till it does. (This works)
The next task (my problem) is that the script should exit if a file
does not exist. The script doesn't exit until it hits the copy command.
I have also tried using "die" but the result was the same.
Thanks
-Mike
OS is SunOS 5.8
do{
&proc_run;
} while $result ne"";
my $inow_fas = "/inow/index-data/sfs-fas/fas.txt";
exit unless (-e $inow_fas);
my $dstamp = `date "+%m-%d-%Y"`;
chomp $inow_fas;
my $renamed_file = $inow_fas.$dstamp;
chomp $renamed_file;
`cp $inow_fas $renamed_file`;
--- snip (do other stuff) ---
sub proc_run{
$result =`ps -aef|grep writekeyscmdline|grep -v grep`;
sleep 60 if $result =~ m/writekeyscmdline/;
}
In the crontab I output all errors to a file in the /tmp directory. test -s is then used to see if the file is greater than 0, and if so the output is mailed to me.
I would like to have the script exit with a descriptive error message.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.