Ahmed Moustafa Ibrahim Ahmed wrote:
> 
> In Perl, how can I know that a file is being opened by any other process
> i.e. being edited or transferred (FTP)?
> 
> I made following function but it's very slow because of the using of "lsof":

You are also using "grep" and "wc".

> ---------------------------------------------------------------
> sub is_open {
>     local ($file) = @_;
>     $flag = qx ( $settings{'lsof'} | grep $file | wc -l);
>     $flag =~ s/^\s+//;
>     $flag =~ s/\s+$//;
>     if ($flag == 0) {
>         return "";
>     } else {
>     return 1;
>     }
> }

It is kind of hard to test without the actual command line settings for
"lsof".



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to