Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to keep the script from stopping or hanging

Reply
Thread Tools

How to keep the script from stopping or hanging

 
 
Nene
Guest
Posts: n/a
 
      04-07-2012
Hi,

This script below stops and hangs after it fails to find the directory
in the following code:
chdir("/c\$/$stuff/") || die "cannot cd into /c\$/$stuff ($!)";

Here is the output it gets when it doesn't find the directory:
cannot cd into /c$/blah (No such file or directory) at ./start_blah.pl
line 12, <SCRATCHPAD> line 40.

But I don't want it to stop, I want it to proceed. How do I go about
getting that?


#!/usr/bin/perl -w
print "\n";
print "Starting .....\n";

open(SCRATCHPAD,"LOG.txt") or die "can't open $!";

my @uniq = <SCRATCHPAD>;

foreach my $stuff ( @uniq ) {
chomp($stuff);

chdir("/c\$/$stuff/") || die "cannot cd into /c\$/$stuff ($!)";

open(STARTUP, "/c\$/$stuff/startup |");

system('sleep 10');

}
close(STARTUP);
close(SCRATCHPAD);
 
Reply With Quote
 
 
 
 
Peter J. Holzer
Guest
Posts: n/a
 
      04-07-2012
On 2012-04-07 12:25, Nene <> wrote:
> This script below stops and hangs after it fails to find the directory
> in the following code:
> chdir("/c\$/$stuff/") || die "cannot cd into /c\$/$stuff ($!)";
>
> Here is the output it gets when it doesn't find the directory:
> cannot cd into /c$/blah (No such file or directory) at ./start_blah.pl
> line 12, <SCRATCHPAD> line 40.
>
> But I don't want it to stop, I want it to proceed. How do I go about
> getting that?


Look up what "die" does.

hp


--
_ | Peter J. Holzer | Deprecating human carelessness and
|_|_) | Sysadmin WSR | ignorance has no successful track record.
| | | |
__/ | http://www.hjp.at/ | -- Bill Code on
 
Reply With Quote
 
 
 
 
Nene
Guest
Posts: n/a
 
      04-07-2012
On Apr 7, 9:21*am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2012-04-07 12:25, Nene <rodbas...@gmail.com> wrote:
>
> > This script below stops and hangs after it fails to find the directory
> > in the following code:
> > chdir("/c\$/$stuff/") || die "cannot cd into /c\$/$stuff ($!)";

>
> > Here is the output it gets when it doesn't find the directory:
> > cannot cd into /c$/blah (No such file or directory) at ./start_blah.pl
> > line 12, <SCRATCHPAD> line 40.

>
> > But I don't want it to stop, I want it to proceed. *How do I go about
> > getting that?

>
> Look up what "die" does.


Thanks, I took out the "die", the script doesn't stop anymore.
>
> * * * * hp
>
> --
> * *_ *| Peter J. Holzer * *| Deprecating human carelessness and
> |_|_) | Sysadmin WSR * * * | ignorance has no successful track record.
> | | * | h...@hjp.at * * * * |
> __/ * |http://www.hjp.at/| *-- Bill Code on a...@irtf.org


 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      04-07-2012
Nene <> wrote:
>This script below stops and hangs after it fails to find the directory
>in the following code:
>chdir("/c\$/$stuff/") || die "cannot cd into /c\$/$stuff ($!)";
>
>But I don't want it to stop, I want it to proceed. How do I go about
>getting that?


Maybe don't tell the script to "die()"?

jue
 
Reply With Quote
 
Randal L. Schwartz
Guest
Posts: n/a
 
      04-07-2012
>>>>> "Nene" == Nene <> writes:

Nene> chdir("/c\$/$stuff/") || die "cannot cd into /c\$/$stuff ($!)";

Nene> But I don't want it to stop, I want it to proceed. How do I go about
Nene> getting that?

But then it'll be in the wrong directory. The chdir() is there for a
reason, and apparently relatively mandatory, for the original author to
put the die there in the first place.

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
 
Reply With Quote
 
Abhishek Jain
Guest
Posts: n/a
 
      04-09-2012
Does anyone think of WARN ??
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How keep python socket alive for ever by setting Keep alive flag. hisan Python 1 06-25-2012 05:30 PM
How to troubleshoot hanging script? kj Python 2 08-06-2008 07:34 AM
Avoiding bad <SCRIPT SRC=> hanging the page Pascal Damian Javascript 14 08-12-2004 05:22 PM
Pop-ups keep a popping and IE keeps hanging JnlSeb Computer Information 0 11-04-2003 09:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57