Ramprasad wrote:
> I have written a simple script that runs file when I run on command line
> but fails when I redirect its output
>
> I cant beleive this , it seems so impossible can anyone help me
>
> $!=1;

Should be $| = 1 for autoflush. Or, more neatly:

    use IO::Handle;
    autoflush STDOUT;

> use Net::Ping;
> @host_array = <DATA>;
> $p = Net::Ping->new("icmp");
> $p->bind("192.168.2.211"); # Specify source interface of pings

I don't know of a 'bind' method for this module. I may be new, of course.

> foreach $host (@host_array)  {
>    chomp($host);
>    print "$host is ";
>    print "NOT " unless $p->ping($host, 2);

I'd try the program with the ping line commented out, so that all it's
doing is dumping your data. Then see if you can redirect that.

>    print "reachable.\n";
> }
> $p->close();
> __DATA__
[snip data]
>
>
> When I run the above script it runs fine like this
>   perl ping1.pl
>
> when I do
> perl ping1.pl >output
> I get nothing on screen
> the file output  is also empty 8-(
>
> Now How can this happen

I can't imagine! But try writing a simple 'Hello World!' program
and making sure you can redirect from that, then enhance it
stepwise until it does what this one does!

DO let us know when you find the answer!

Cheers,

Rob




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

Reply via email to