CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
How to save a file from a WWW:Curl::Easy request in a specific directory.

 



manuel2590
New User

Jul 15, 2016, 6:25 AM

Post #1 of 1 (4837 views)
How to save a file from a WWW:Curl::Easy request in a specific directory. Can't Post

Hello Everyone,

Im new in this forum and i want to ask you something about the WWW::Curl::Easy in perl. I´ve ben trying to save the generated file in xml or csv format in a specific directory but my tries fails.


Code
use strict; 
use warnings;
#use Text::CSV; #Función para lectura de archivo CSV - Historic data
use Config::Properties; #Para leer el file properties
use WWW::Curl::Easy; #Para realizar el Curl request
use Data::Dumper qw(Dumper);
use 5.010; #Versión para eluse de arriba.
#use POSIX qw/strftime/; # Funcion para extraer fecha y hora del servidor donde se ejecuta
use XML::Simple; # Funcion para extraer data de un archivo XML - Live Data
use Excel::Writer::XLSX; # Funcion para escritura sobre archivos Excel - New Data

#############################################
use constant ownPropertiesFile => "/home/nssdatabase/scripts/Pruebas/Properties.properties";
use vars qw($properties);

# Carga del archivo de propiedades del script
open (PROPS, ownPropertiesFile);
my $ownProperties = new Config::Properties();
$ownProperties->load(*PROPS);
close (PROPS);

# Verificación del archivo de propiedades del script
if (! -s ownPropertiesFile) {&CloseScript ("Error: The properties file (" . ownPropertiesFile . ") doesn't exist or it's empty.", 1);}

# Carga de directorios a utilizar
my $host = $ownProperties->getProperty("host");
my $user = $ownProperties->getProperty("user");
my $pass = $ownProperties->getProperty("pass");
my $id = $ownProperties->getProperty("id");
my $avg = $ownProperties->getProperty("avg");
my $sdate = $ownProperties->getProperty("sdate");
my $edate = $ownProperties->getProperty("edate");

my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_HEADER,1);
$curl->setopt(CURLOPT_URL, '
http://$host/api/historicdata.csv?id=$id&avg=$avg&sdate=$sdate&edate=$edate&username=$user&password=$pass');


Please tell me what lines i have to add into my script to do that.


(This post was edited by FishMonger on Jul 15, 2016, 6:44 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives