Doing what you propose is possible, but would take system resources and a
bit tedious.

Here's an alternate solution:

>From what I infer, you are processing on a file and then the code decides if
its a success or a failure and your job is to remove tmp files if it fails.
Here, when the processing code is done with its job, ask it to return an
exit status (say  return1 for success and 0 for failure). Then based on this
return status, you can do your job.

If itsn't clear, get back

-susheel

On Tue, Nov 11, 2008 at 6:18 AM, satish km <[EMAIL PROTECTED]> wrote:

> Hi,
>
> My requirement is like this:
>
> 1. There are 1000 files in a directory(DIR1)
> 2. When processing is started, ex file1 wil be converted to temp_file1,
> then processed and both file1 + temp_file1 are removed from DIR1 within 2-3
> seconds.
>
> if any temp_file* (ex: temp_file6) is still present in DIR1 means
> processing failed.
>
> So I need to periodically check in if any temp_file* generated is staying
> for more than 30 seconds (which means processing failed), then I hv to move
> this temp_file* to some other folder and restart processing again of the
> remaining files.
>
> I am trying to achieve this using perl. Can u plz let me know how to
> achieve this.
>
> Thanks,
> Satish
>
>
> On Tue, Nov 11, 2008 at 5:11 AM, Susheel Koushik <[EMAIL PROTECTED]>wrote:
>
>>  use the PERL system command. Its a wrapper for system call on your host
>> OS.
>>
>> ex: system("mv $filename $new_location/$filename");
>>
>> susheel
>>
>>   On Mon, Nov 10, 2008 at 4:39 PM, Susheel Koushik <[EMAIL PROTECTED]>wrote:
>>
>>> use the PERL system command. Its a wrapper for system call on your host
>>> OS.
>>>
>>> ex: system("rm *.tmp");
>>>
>>> susheel
>>>
>>>   On Mon, Nov 10, 2008 at 3:32 AM, [EMAIL PROTECTED] <
>>> [EMAIL PROTECTED]> wrote:
>>>
>>>> Hi Everyone,
>>>>
>>>> I have around 2000 files in a directory. During processing of these
>>>> files, a temp* will be created for each file and its removed after
>>>> processing that file. If the processing is unsuccessful, temp* file
>>>> still exists. Can u plz help me to write a script to automate this
>>>> process using Perl ie., when a temp* file is found (which stays for
>>>> abt 10 secs max), I hv to move that temp* file to some other folder.
>>>>
>>>> Thanks in advance,
>>>> Satish
>>>>
>>>>
>>>> --
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>> http://learn.perl.org/
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Susheel Koushik M
>>> Graduate Student
>>> Ira A Fulton School of Engineering
>>> Arizona State University
>>>
>>
>>
>>
>> --
>> Susheel Koushik M
>> Graduate Student
>> Ira A Fulton School of Engineering
>> Arizona State University
>>
>
>


-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University

Reply via email to