-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot_config.pl
73 lines (53 loc) · 1.6 KB
/
robot_config.pl
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl -w
# RobotConfiguration
use strict;
use Net::FTP;
use Getopt::Long;
use Cwd;
my $CONFIG_FILE = 'C:/WindRiver/workspace/SimpleTemplate/config.txt';
my $DO_VERBOSE = undef;
my $DO_DEBUG = undef;
my $ROBOT_IP = '10.17.41.2';
sub info {
print STDOUT "verbose ",$_[0],"\n" if $DO_VERBOSE or $DO_DEBUG;
}
sub debug {
print STDOUT "debug: ",$_[0],"\n" if $DO_DEBUG;
}
sub main {
GetOptions('config|c=s' => \$CONFIG_FILE,
'verbose|v' => \$DO_VERBOSE,
'debug|d' => \$DO_DEBUG,
'robot|r=s' => \$ROBOT_IP);
debug("Debug mode enabled.");
if (! (-e $CONFIG_FILE)) {
die "Cannot find $CONFIG_FILE";
}
debug("Creating ftp client.");
my $ftp_d = 0;
if ($DO_DEBUG) {
$ftp_d = 1;
}
my $ftp = Net::FTP->new($ROBOT_IP, Debug => $ftp_d)
or die "Cannot connect to $ROBOT_IP: $@";
debug("Client created.");
debug("Logging in...");
$ftp->login("foo",'bar')
or die "Cannot login ", $ftp->message;
debug("Logged in.");
#debug("Switching to root directory...");
#$ftp->cwd("/")
# or die "Cannot change working directory ", $ftp->message;
#debug("Directory switched.");
$ftp->ascii;
debug("Sending file...");
$ftp->put($CONFIG_FILE)
or die "send failed ", $ftp->message;
debug("Done.");
#$ftp->get("that.file")
# or die "get failed ", $ftp->message;
debug("Logging out...");
$ftp->quit;
debug("Finished.");
}
main();