#!/usr/bin/perl 
use warnings;
use strict;
use feature ':5.10';
use WWW::Curl::Easy;
use Getopt::Std;
our ($opt_u, $opt_p, $opt_c, $opt_v);
getopts('u:p:c:v');

my $username = $opt_u or die "Username required";
my $password = $opt_p or die "Password required";

my $verbose = 0;
if ($opt_v) { $verbose = 1; }

my $cmd = 'HELP';
if ($opt_c eq 't') { $cmd = 'TIME'};
if ($opt_c eq 'u') { $cmd = 'UTIME'};
if ($opt_c eq 'i') { $cmd = 'IDLE'};
if ($opt_c eq 'h') { $cmd = 'HELP'};

my $url = 'ftp://10.5.1.6/';
my $curl = WWW::Curl::Easy->new() or die "Can not create curl object";
$curl->setopt(CURLOPT_VERBOSE,$verbose);
$curl->setopt(CURLOPT_URL,$url);
$curl->setopt(CURLOPT_USERPWD,"$username:$password");
$curl->setopt(CURLOPT_CUSTOMREQUEST,"SITE $cmd");
#my @cmd = ( "SITE $cmd", "QUIT" );
#$curl->setopt(CURLOPT_QUOTE, \@cmd);
my $response = $curl->perform();
if ( $response == 0) {
  say "Success $response ", $curl->errbuf;
}
else {
  say "Failed: $response ", $curl->errbuf;
}


