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];
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" |};
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.
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";
As an alternative (and not needing an external program), you could use LWP::UserAgent to fetch the document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With