I am running a command on remote host to grab some data, i want to stop at a 
certain size. the following seem to be working (file size does not grow beyond 
1MB on disk), but the process keeps running till i guess everything coming from 
that 'pipe' is finished.

how can i stop/break/close the pipe as soon as i reach the limit?


my $ssh = Net::OpenSSH->new($host);
...

                my ($rout, $pid) = $ssh->pipe_out($cmd);

                    while (my $line = <$rout>) {
                        my 
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)=
 stat($tmp_fh);
                        if ($size < $huge_limit ){
                            print $tmp_fh $line;
                            } else {
                            print $tmp_fh "reached File Size limit.";
                            last;
                            }
                        }

this just simply times out. does not print any error message in the opened 
file. does stat operation affect the pointer inside the file?

ty.

Reply via email to