How to create a folder in ftp using perl

W

windqin

Hello I'm a perl beginner, I want to create a folder in a ftp using
perl, can anyone give me a help?
I know to use Net::FTP reference, but I don't know the detail function
to create a folder.
 
S

Simon Taylor

Hello Perl beginner with no name,
Hello I'm a perl beginner, I want to create a folder in a ftp using
perl, can anyone give me a help?
I know to use Net::FTP reference, but I don't know the detail function
to create a folder.

Try this (after modifying to add in your own values for $host, $login
and $passwd):

Regards,

Simon Taylor


#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;

my $host = 'nnn.nnn.nnn.nnn';
my $debug = 0;
my $login = 'xxxxxx';
my $passwd = 'xxxxxx';
my $folder = 'new_folder';

my $ftp = Net::FTP->new($host, Debug => $debug)
or die "Cannot connect to $host";

$ftp->login($login, $passwd)
or die "Cannot login to $host";

$ftp->mkdir($folder)
or die "Cannot create $folder " . $ftp->message;

$ftp->quit();
exit 0;
 
W

windqin

Really thank you :)
Now everything is OK.


Simon said:
Hello Perl beginner with no name,


Try this (after modifying to add in your own values for $host, $login
and $passwd):

Regards,

Simon Taylor


#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;

my $host = 'nnn.nnn.nnn.nnn';
my $debug = 0;
my $login = 'xxxxxx';
my $passwd = 'xxxxxx';
my $folder = 'new_folder';

my $ftp = Net::FTP->new($host, Debug => $debug)
or die "Cannot connect to $host";

$ftp->login($login, $passwd)
or die "Cannot login to $host";

$ftp->mkdir($folder)
or die "Cannot create $folder " . $ftp->message;

$ftp->quit();
exit 0;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top