Do not use on any
shared computer
July 24, 2008 07:47pm pdt
null
[x]
Attachment Details

Problem with broken pipe

Tags: pipe, broken, perl
Hi All,
I have a script written by someone else and I am still learning perl.  What the script does is monitor ftp uploads through a pipe and then processes them.  The problem is, something is causing the pipe to break and the script then stops.  How do I get the script to recover and continue processing.  Below is a portion of the system log that shows what is happening when it breaks and a portion of the code.  I would also like to know how I can get it to process only a few files at a time.  If there is a really fast upload connection and a lot of files I get a lot of processes running that bog down the system.  I would prefer to be able to put a limit on the number files being processed at one time before processing the rest.

I am putting this at 500 because I need this fixed soon and it is over my head.
Thanks


Jun 15 13:01:37 x ftpd[11453]: xferlog (recv): 1 64.25.14.122 1063001 /Users/ftpuser/17298/af_1377.JPG b _ i r ftpuser ftp 0 * c
Jun 15 13:01:38 x ftpd[11453]: xferlog (recv): 1 64.25.14.122 859339 /Users/ftpuser/17298/ag_1435.JPG b _ i r ftpuser ftp 0 * c
Jun 15 13:01:39 x ftpd[11453]: xferlog (recv): 1 64.25.14.122 1104033 /Users/ftpuser/17298/ah_1378.JPG b _ i r ftpuser ftp 0 * c
Jun 15 13:01:41 x ftpd[11453]: xferlog (recv): 1 64.25.14.122 1122386 /Users/ftpuser/17298/ai_1382.JPG b _ i r ftpuser ftp 0 * c
Jun 15 13:01:42 x ftpd[11453]: xferlog (recv): 1 64.25.14.122 1055950 /Users/ftpuser/17298/aj_1380.JPG b _ i r ftpuser ftp 0 * c
Jun 15 13:01:43 x kernel: AppleBCM5701Ethernet:        0        1 timeoutOccurred - FCS errors noted, resetting
Jun 15 13:01:43 x syslogd: /var/log/online: Broken pipe
Jun 15 13:01:43 x /usr/sbin/AppleFileServer: AFPServer::AbnormalATListenerShutDown - clear listener
Jun 15 13:01:47 x kernel: AppleBCM5701Ethernet:        0        4 setupCopperPhy - link is down
Jun 15 13:01:50 x kernel: AppleBCM5701Ethernet - en0 link active, 1000-Mbit, full duplex, flow control enabled
Jun 15 13:01:51 x ftpd[11453]: xferlog (recv): 1 64.25.14.122 974607 /Users/ftpuser/17298/ak_1386.JPG b _ i r ftpuser ftp 0 * c
Jun 15 13:01:53 x ftpd[11453]: xferlog (recv): 2 64.25.14.122 1073889 /Users/ftpuser/17298/al_1375.JPG b _ i r ftpuser ftp 0 * c


Script:

if ( open(PID, '/var/run/syslog.pid') && <PID> =~ /^(\d+)$/ && kill(0, $1) ) {
      my $pid = $1;

      close(PID);

      system("kill -9 $pid");

      system("cd / ; /usr/sbin/syslogd >/dev/null 2>/dev/null </dev/null &");
}

$SIG{'CHLD'} = 'IGNORE';

while (1) {
      open(FIFO, "< /var/log/online") || warn $!;
      my $log_line = <FIFO>;
      close(FIFO);

      next unless defined $log_line && $log_line =~ 'xferlog';

      print $log_line;

      my ($m, $d, $t, $h, $p, $x, $r,
            $seconds, $ip, $size, $file, $type, $u,
            $action, $direction, $user,
            $service, $auth, $a, $complete) = split(/\s+/, $log_line);

      next if !$file;

      &handle_image($file) if $user eq $username && -e $file;
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: kareed
Solution Provided By: jmcg
Participating Experts: 2
Solution Grade: B
Views: 49
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by jmcg

Rank: Sage

Expert Comment by jmcg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by manav_mathur

Rank: Wizard

Expert Comment by manav_mathur:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by kareed
Author Comment by kareed:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by jmcg

Rank: Sage

Accepted Solution by jmcg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by kareed
Author Comment by kareed:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by kareed
Author Comment by kareed:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34