version 1.13, 2001/04/08 20:52:55 |
version 1.14, 2001/04/12 23:17:54 |
|
|
void |
void |
usage(void) |
usage(void) |
{ |
{ |
fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host\n"); |
fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host[:file [file]]\n"); |
exit(1); |
exit(1); |
} |
} |
|
|
|
|
{ |
{ |
int in, out, ch, debug_level, compress_flag; |
int in, out, ch, debug_level, compress_flag; |
pid_t sshpid; |
pid_t sshpid; |
char *host, *userhost; |
char *file1 = NULL; |
|
char *host, *userhost, *cp, *file2; |
LogLevel ll; |
LogLevel ll; |
extern int optind; |
extern int optind; |
extern char *optarg; |
extern char *optarg; |
|
|
} |
} |
} |
} |
|
|
if (optind == argc || argc > (optind + 1)) |
if (optind == argc || argc > (optind + 2)) |
usage(); |
usage(); |
|
|
userhost = xstrdup(argv[optind]); |
userhost = xstrdup(argv[optind]); |
|
file2 = argv[optind+1]; |
|
|
|
if ((cp = strchr(userhost, ':')) != NULL) { |
|
*cp++ = '\0'; |
|
file1 = cp; |
|
} |
|
|
if ((host = strchr(userhost, '@')) == NULL) |
if ((host = strchr(userhost, '@')) == NULL) |
host = userhost; |
host = userhost; |
else { |
else { |
*host = '\0'; |
*host++ = '\0'; |
if (!userhost[0]) { |
if (!userhost[0]) { |
fprintf(stderr, "Missing username\n"); |
fprintf(stderr, "Missing username\n"); |
usage(); |
usage(); |
} |
} |
make_ssh_args("-l"); |
make_ssh_args("-l"); |
make_ssh_args(userhost); |
make_ssh_args(userhost); |
host++; |
|
} |
} |
|
|
if (!*host) { |
if (!*host) { |
|
|
|
|
connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid); |
connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid); |
|
|
interactive_loop(in, out); |
interactive_loop(in, out, file1, file2); |
|
|
close(in); |
close(in); |
close(out); |
close(out); |