fabiano petrone
asked on
Perl System script - format of the output
Hello,
I must "execute" some commands on some books (scan-in of the items) using POST API and I've tought at a call to the CURL command via system.
Say we have a input.csv with all the books data.
The script is called via:
In output.txt I've some interesting data returned by the server at EVERY CURL call.
The question is simple: my I add a bit of format to output.txt (I.E. separe the output of every CURL call with something like "***BEGIN NEW OUTPUT****)?
Thanks,
Fabiano
I must "execute" some commands on some books (scan-in of the items) using POST API and I've tought at a call to the CURL command via system.
Say we have a input.csv with all the books data.
The script is called via:
perl script.pl<input.csv>output.txt
the simple script is the following:#!/usr/bin/perl
# open(FD_IN, "<STDIN") || die "Errore apertura standard input";
while (<STDIN>) {
$Riga = $_;
$Riga =~ s/\n//;
$Riga =~ s/\r//;
@Campi = split("\t", $Riga);
system("curl -X POST -H \"Content-Type: application/xml\" \"https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/".$Campi[2]."/holdings/".$Campi[1]."/items/".$Campi[0]."?op=scan&library=PETFS&circ_desk=DEFAULT_CIRC_DESK&done=true&apikey=xxxxxxxxxx\"\n");
$cntRecord++;
}
# close(FD_IN);
In output.txt I've some interesting data returned by the server at EVERY CURL call.
The question is simple: my I add a bit of format to output.txt (I.E. separe the output of every CURL call with something like "***BEGIN NEW OUTPUT****)?
Thanks,
Fabiano
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm honestly not sure. I've never used either module (I haven't needed to use curl much and it's been a long time since I did any web-grabbing/scraping for my job).
ASKER
you're right! I've not though to this simple & good solution! :=)
I need only a "quick & dirty" parsing of a lot of API URLs (pratically, every URL is something like a "scan" operation of a book barcode done with a barcode reader) so I've not examined other solutions.
Is there any advantage using WWW::Curl or LWP::Curl
Thanks,
Fabiano