perl: feeding stdin of executed command
You may use open
to open pipe to executed program (lftp
) input.
open( my $LFTP,'|-', "lftp -u $ftpuser,$pass -e open $hostname" )
or die "Cannot open lftp: $!";
print $LFTP <<"END";
set ftp:ssl-allow no
set mirror:use-pget-n 5
glob -a rm -r 'remote_dir/db-import.php'
END
close($LFTP) or die; # die unless lftp exit code is 0
Alternative method: Using module like IPC::Run
allows to check executed command replies.