version 1.38, 2003/10/08 08:27:36 |
version 1.39, 2004/01/13 09:25:05 |
|
|
#include "sftp-client.h" |
#include "sftp-client.h" |
#include "sftp-int.h" |
#include "sftp-int.h" |
|
|
FILE* infile; |
FILE* infile = stdin; |
|
int batchmode = 0; |
size_t copy_buffer_len = 32768; |
size_t copy_buffer_len = 32768; |
size_t num_requests = 16; |
size_t num_requests = 16; |
static pid_t sshpid = -1; |
static pid_t sshpid = -1; |
|
|
addargs(&args, "-oForwardAgent no"); |
addargs(&args, "-oForwardAgent no"); |
addargs(&args, "-oClearAllForwardings yes"); |
addargs(&args, "-oClearAllForwardings yes"); |
ll = SYSLOG_LEVEL_INFO; |
ll = SYSLOG_LEVEL_INFO; |
infile = stdin; /* Read from STDIN unless changed by -b */ |
|
|
|
while ((ch = getopt(argc, argv, "1hvCo:s:S:b:B:F:P:R:")) != -1) { |
while ((ch = getopt(argc, argv, "1hvCo:s:S:b:B:F:P:R:")) != -1) { |
switch (ch) { |
switch (ch) { |
|
|
ssh_program = optarg; |
ssh_program = optarg; |
break; |
break; |
case 'b': |
case 'b': |
if (infile == stdin) { |
if (batchmode) |
infile = fopen(optarg, "r"); |
fatal("Batch file already specified."); |
if (infile == NULL) |
|
fatal("%s (%s).", strerror(errno), optarg); |
/* Allow "-" as stdin */ |
} else |
if (strcmp(optarg, "-") != 0 && |
fatal("Filename already specified."); |
(infile = fopen(optarg, "r")) == NULL) |
|
fatal("%s (%s).", strerror(errno), optarg); |
showprogress = 0; |
showprogress = 0; |
|
batchmode = 1; |
break; |
break; |
case 'P': |
case 'P': |
sftp_direct = optarg; |
sftp_direct = optarg; |
|
|
sftp_server : "sftp")); |
sftp_server : "sftp")); |
args.list[0] = ssh_program; |
args.list[0] = ssh_program; |
|
|
fprintf(stderr, "Connecting to %s...\n", host); |
if (!batchmode) |
|
fprintf(stderr, "Connecting to %s...\n", host); |
connect_to_server(ssh_program, args.list, &in, &out); |
connect_to_server(ssh_program, args.list, &in, &out); |
} else { |
} else { |
args.list = NULL; |
args.list = NULL; |
addargs(&args, "sftp-server"); |
addargs(&args, "sftp-server"); |
|
|
fprintf(stderr, "Attaching to %s...\n", sftp_direct); |
if (!batchmode) |
|
fprintf(stderr, "Attaching to %s...\n", sftp_direct); |
connect_to_server(sftp_direct, args.list, &in, &out); |
connect_to_server(sftp_direct, args.list, &in, &out); |
} |
} |
|
|
|
|
|
|
close(in); |
close(in); |
close(out); |
close(out); |
if (infile != stdin) |
if (batchmode) |
fclose(infile); |
fclose(infile); |
|
|
while (waitpid(sshpid, NULL, 0) == -1) |
while (waitpid(sshpid, NULL, 0) == -1) |