version 1.9, 2001/03/03 23:52:22 |
version 1.10, 2001/03/06 06:11:44 |
|
|
int use_ssh1 = 0; |
int use_ssh1 = 0; |
char *ssh_program = _PATH_SSH_PROGRAM; |
char *ssh_program = _PATH_SSH_PROGRAM; |
char *sftp_server = NULL; |
char *sftp_server = NULL; |
|
FILE* infile; |
|
|
void |
void |
connect_to_server(char **args, int *in, int *out, pid_t *sshpid) |
connect_to_server(char **args, int *in, int *out, pid_t *sshpid) |
|
|
void |
void |
usage(void) |
usage(void) |
{ |
{ |
fprintf(stderr, "usage: sftp [-1vC] [-osshopt=value] [user@]host\n"); |
fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host\n"); |
exit(1); |
exit(1); |
} |
} |
|
|
|
|
extern int optind; |
extern int optind; |
extern char *optarg; |
extern char *optarg; |
|
|
|
infile = stdin; /* Read from STDIN unless changed by -b */ |
debug_level = compress_flag = 0; |
debug_level = compress_flag = 0; |
|
|
while ((ch = getopt(argc, argv, "1hvCo:s:S:")) != -1) { |
while ((ch = getopt(argc, argv, "1hvCo:s:S:b:")) != -1) { |
switch (ch) { |
switch (ch) { |
case 'C': |
case 'C': |
compress_flag = 1; |
compress_flag = 1; |
|
|
case 'S': |
case 'S': |
ssh_program = optarg; |
ssh_program = optarg; |
break; |
break; |
|
case 'b': |
|
if (infile == stdin) { |
|
infile = fopen(optarg, "r"); |
|
if (infile == NULL) |
|
fatal("%s (%s).", strerror(errno), optarg); |
|
} else |
|
fatal("Filename already specified."); |
|
break; |
case 'h': |
case 'h': |
default: |
default: |
usage(); |
usage(); |
|
|
|
|
close(in); |
close(in); |
close(out); |
close(out); |
|
if (infile != stdin) |
|
fclose(infile); |
|
|
if (waitpid(sshpid, NULL, 0) == -1) |
if (waitpid(sshpid, NULL, 0) == -1) |
fatal("Couldn't wait for ssh process: %s", strerror(errno)); |
fatal("Couldn't wait for ssh process: %s", strerror(errno)); |