Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Wget using backquotes

by zentara (Archbishop)
on Feb 18, 2007 at 16:41 UTC ( [id://600711]=note: print w/replies, xml ) Need Help??


in reply to Wget using backquotes

wget is one of those apps that dosn't play nice with backticks. It writes directly to the tty, and sends some messages to STDERR. You can try this with IPC::Open3, but you might need to use IO::Pty.
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; use IO::Select; my $pid = open3(0, \*READ,\*ERROR,"wget --spider -nv http://zentara.n +et"); my $sel = new IO::Select(); $sel->add(\*READ); $sel->add(\*ERROR); my($error,$answer)=('',''); foreach my $h ($sel->can_read) { my $buf = ''; if ($h eq \*ERROR) { sysread(ERROR,$buf,4096); if($buf){print "ERROR-> $buf\n"} } else { sysread(READ,$buf,4096); if($buf){print "response->$buf\n"} } } waitpid($pid, 1);
Output: ERROR-> 200 OK

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://600711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-04-25 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found