forked from BigRedS/play
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathptfe
More file actions
executable file
·52 lines (37 loc) · 920 Bytes
/
Copy pathptfe
File metadata and controls
executable file
·52 lines (37 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/perl
# Handy script to make commonly-repeated ftp uploads
# quicker and more painless.
use strict;
use Net::FTP;
#my $config_file = "$ENV{HOME}/.ptfe";
my $config_file = "./.ptfe";
my %config;
open (F, "<$config_file");
while(<>){
chomp;
my($key,$value)=(split(/=/, $_))[0,1];
$config{$key}=$value;
}
close F;
print $config{username};
exit 0;
## Credentials:
my $hostname="localhost";
my $username="username";
my $password="Password";
# Once we're connected, we'll cd to this dir:
my $cwd="www";
# And upload this file (the first argument):
my $file = $ARGV[0];
##
my $ftp;
$ftp = Net::FTP->new("$hostname", Debug => 0)
or die("Error connecting: ", $ftp->message);
$ftp->login($username, $password)
or die("Error logging in: ", $ftp->message);
if ($cwd){
$ftp->cwd($cwd)
or die("cwd (to $cwd) failed: ", $ftp->message);
}
$ftp->put($file)
or die("Put failed: ", $ftp->message);