1 |
#include <ftp.h> |
2 |
#include <string.h> |
3 |
|
4 |
// sunos does not prototype this in stdio.h |
5 |
extern "C" char* getpass (char* prompt); |
6 |
|
7 |
int main (int ac, char** av) |
8 |
{ |
9 |
// this is an ftp client |
10 |
// It retrieves the file from the host through the |
11 |
// nsc firewall. Donot use this outside of NSC. |
12 |
if (ac < 3) { |
13 |
cerr << "USAGE: " |
14 |
<< av [0] |
15 |
<< " user@hostname remotefilepath [localfilename]\n"; |
16 |
return 1; |
17 |
} |
18 |
|
19 |
ftp f (&cout); |
20 |
|
21 |
// establish connection |
22 |
f->connect ("gatekeeper.nsc.com"); |
23 |
f->get_response (); // get the connection response |
24 |
|
25 |
// set access |
26 |
f->user (av [1]); |
27 |
f->passwd (getpass ("Password: ")); |
28 |
|
29 |
// get help |
30 |
f->help (); |
31 |
|
32 |
// set representation type to image |
33 |
f->rep_type (ftp::rt_image); |
34 |
|
35 |
// get a file |
36 |
char* p = strrchr (av [2], '/'); |
37 |
if (p == 0) |
38 |
p = av [2]; |
39 |
else |
40 |
p++; |
41 |
f->getfile (av [2], av [3] ? av [3]: p); |
42 |
|
43 |
// quit |
44 |
f->quit (); |
45 |
} |
46 |
|