Home > Archive > PERL Beginners > March 2005 > Create unexistent directories by FTP
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Create unexistent directories by FTP
|
|
| Marcos Rebelo 2005-03-28, 3:56 pm |
| I have a program that is supposed to send files throw FTP. And I'm
using the Net::FTP. I have a destiny path and I need to create the
directories if they don't exist.
How do I check if a Directory exist?
Actual code +-:
sub fput($$$) {
my ($ftp, $orig, $dest) = @_;
return if $orig =~ /xpto/;
$dest = File::Spec->canonpath($dest);
if (-f $orig) {
my ($volume,$directories,$file) = File::Spec->splitpath($dest);
$ftp->mkdir($directories, 1) or print "Can't create directory:
", $ftp->message();
if ($ftp->put($orig, $dest)) {
print "file '$orig' sent.\n";
} else {
print "Can't put: ", $ftp->message();
}
} elsif (-d $orig) {
print "directory '$orig' not sent.\n";
} else {
die "Path '$orig' is not recognized\n".HELP;
}
}
| |
| Marcos Rebelo 2005-03-28, 3:56 pm |
| Hy
In the remote machine.
I know how to create it, but I don't like to have a big error log.
Eatch request creates log entraces, but if the directory already
exists, creates also error logs.
Marcos
On Mon, 28 Mar 2005 19:08:32 +0200 (CEST), Steven Schubiger
<steven@accognoscere.org> wrote:
> On 28 Mar, marcos rebelo wrote:
>
>
> Locally or remotely?
>
>
> -e $dir for local purposes
>
> Steven
>
| |
| Steven Schubiger 2005-03-28, 8:56 pm |
| > On 28 Mar, marcos rebelo wrote:
> I have a program that is supposed to send files throw FTP. And I'm
> using the Net::FTP. I have a destiny path and I need to create the
> directories if they don't exist.
Locally or remotely?
> How do I check if a Directory exist?
-e $dir for local purposes
Steven
| |
| JupiterHost.Net 2005-03-28, 8:56 pm |
|
marcos rebelo wrote:
> I have a program that is supposed to send files throw FTP. And I'm
> using the Net::FTP. I have a destiny path and I need to create the
> directories if they don't exist.
>
> How do I check if a Directory exist?
If you can wait a couple days Net::FTP::File
(http://search.cpan.org/~dmuey/) does this and more.
The author is releasing soon and we've been using it to try it out for
him, its pretty slick
HTH
Lee.M
|
|
|
|
|