Click here to get back home

why is return always 0?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
why is return always 0? jammer 03-16-2008
Posted by xhoster on March 17, 2008, 5:21 pm
Please log in for more thread options
> On Mar 16, 9:10 pm, sandy_sayda...@yahoo.com wrote:
> >
> > > How do I make tftp fail if the host is bad?

It seems that that is a question for the authors of tftp, not
a Perl question. But there may be a Perl work-a-round.

> >
> > > my $rc = system( "/usr/bin/tftp bad$host < $tempFile 2>&1
> > > >/dev/null" ); if ( $rc != 0 ) {
> > > print "unable to tftp to '$host'\n";
> > > exit 1;
> > > } else {
> > > print "success: $rc\n";
> > > }
> >
> > Make sure the binary returns non-zero on failure. Try that command on
> > the command line and do "echo $?" right after.
> >
> > -sandyhttp://myperlquiz.com/
>
> It prints an error when run interactively.

Does it do that when run noninteractively? You could try capturing and
parsing its stderr. IPC::Run might be a good way. (I think it might also
help you trick tftp into thinking it is running interactively, if that is
necessary.)

> tftp does run, it just can't find the host.
> It returns 0 because it ran, didn't work but it ran. :-(

Well, that was probably a poor design decision. By that criterion, nothing
should ever exit with anything but 0. If it ran, it ran. If it didn't
run, it can't exit with anything at all.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Similar ThreadsPosted
windows program return values vs perl return values from a call to system() -- windows post only October 29, 2005, 6:22 pm
return value October 7, 2005, 3:57 am
Help with 'system' seeming to return too soon... September 13, 2004, 2:08 pm
FAQ: How come exec() doesn't return? October 9, 2004, 5:10 pm
FAQ 8.2 How come exec() doesn't return? March 11, 2005, 12:03 am
=~ return value ? boolean ? May 17, 2005, 3:29 am
FAQ 8.2 How come exec() doesn't return? May 31, 2005, 11:03 pm
return and undef October 4, 2005, 8:35 am
FAQ 8.2 How come exec() doesn't return? October 8, 2005, 4:03 am
strange return value October 18, 2005, 1:14 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap