summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-04-13 00:00:14 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-04-13 00:00:14 +0000
commit63667f6568d0667b91aea46f77d54311dcffb53a (patch)
tree8c6ac90b5d25a71cc96b1cb624edfd8271927aa2 /sftp.c
parent19066a112baff6107781dc337b27e557f43098c2 (diff)
- mouring@cvs.openbsd.org 2001/04/12 23:17:54
[sftp-int.c sftp-int.h sftp.1 sftp.c] Add support for: sftp [user@]host[:file [file]] - Fetch remote file(s) sftp [user@]host[:dir[/]] - Start in remote dir/ OK deraadt@
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sftp.c b/sftp.c
index 7849d949..911a04f2 100644
--- a/sftp.c
+++ b/sftp.c
@@ -24,7 +24,7 @@
#include "includes.h"
-RCSID("$OpenBSD: sftp.c,v 1.13 2001/04/08 20:52:55 deraadt Exp $");
+RCSID("$OpenBSD: sftp.c,v 1.14 2001/04/12 23:17:54 mouring Exp $");
/* XXX: commandline mode */
/* XXX: copy between two remote hosts (commandline) */
@@ -147,7 +147,7 @@ make_ssh_args(char *add_arg)
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);
}
@@ -156,7 +156,8 @@ main(int argc, char **argv)
{
int in, out, ch, debug_level, compress_flag;
pid_t sshpid;
- char *host, *userhost;
+ char *file1 = NULL;
+ char *host, *userhost, *cp, *file2;
LogLevel ll;
extern int optind;
extern char *optarg;
@@ -202,22 +203,27 @@ main(int argc, char **argv)
}
}
- if (optind == argc || argc > (optind + 1))
+ if (optind == argc || argc > (optind + 2))
usage();
userhost = xstrdup(argv[optind]);
+ file2 = argv[optind+1];
+
+ if ((cp = strchr(userhost, ':')) != NULL) {
+ *cp++ = '\0';
+ file1 = cp;
+ }
if ((host = strchr(userhost, '@')) == NULL)
host = userhost;
else {
- *host = '\0';
+ *host++ = '\0';
if (!userhost[0]) {
fprintf(stderr, "Missing username\n");
usage();
}
make_ssh_args("-l");
make_ssh_args(userhost);
- host++;
}
if (!*host) {
@@ -256,7 +262,7 @@ main(int argc, char **argv)
connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid);
- interactive_loop(in, out);
+ interactive_loop(in, out, file1, file2);
#if !defined(USE_PIPES)
shutdown(in, SHUT_RDWR);