Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl: curl: (1) Protocol 'http not supported or disabled in libcurl

Tags:

debugging

perl

Perl Question. I'm trying to get this script running in a debugger.

I've got Aptana + Epic + ActivePerl 5.12.4 working on Windows 7x64. The script is starting fine but I'm getting an error:

curl -sS http://intranet.mycompany.org/directory/directory.xml

The above command works fine... but if I start the debugger I get this error:

curl: (1) Protocol 'http not supported or disabled in libcurl

First part of the script below:

#!/usr/bin/perl
use strict;

use XML::Parser;
use Data::Dumper;

my $url = 'http://intranet.atlanticgeneral.org/directory/directory.xml';
my $output = 'C:\global.gabook';

my $file = "curl -sS '$url' |";
my $parser = new XML::Parser(Style => 'Tree');
my $tree = $parser->parsefile($file)->[1];
like image 732
WernerCD Avatar asked Jul 13 '11 19:07

WernerCD


4 Answers

Windows doesn't like single quotes in commands. Try using double quotes in the command, using qq{} escaping. Just change one line:

my $file = qq{curl -sS "$url" |};
like image 136
Stuart Watt Avatar answered Oct 21 '22 17:10

Stuart Watt


Wooble~

"I'm guessing it's the extra single quotes around $url that's causing it"

When I removed the quotes around the '$url' it worked. Quotes worked in redhat perl, but didn't work in my windows perl debugger:

#!/usr/bin/perl
use strict;

use XML::Parser;
use Data::Dumper;

my $url = 'http://intranet.atlanticgeneral.org/directory/directory.xml';
my $output = 'C:\global.gabook';

my $file = "curl -sS $url |";
my $parser = new XML::Parser(Style => 'Tree');
my $tree = $parser->parsefile($file)->[1];

Posting as answer since Wooble didn't.

like image 3
WernerCD Avatar answered Oct 21 '22 17:10

WernerCD


I was getting the same error when I was using the curl command in my java program as follows

    String command = "curl 'http://google.com'";
     try
       {            
           Process proc = Runtime.getRuntime().exec(command);
        .......
        }catch(Exception e){}

Changing command to the following fixed this error

      String command = "curl http://google.com";

Actually, It may be an issue because of shell interpretor. I used curl command like below example

String command = "curl  -duser.name=hdfs -dexecute=select+*+from+logdata.test; -dstatusdir=test.output http://hostname:50111/templeton/v1/hive";
like image 2
minhas23 Avatar answered Oct 21 '22 16:10

minhas23


As an alternative (and not needing an external program), you could use LWP::UserAgent to fetch the document.

like image 1
Skud Avatar answered Oct 21 '22 16:10

Skud