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 7849d9491..911a04f24 100644
--- a/sftp.c
+++ b/sftp.c
@@ -24,7 +24,7 @@
24 24
25#include "includes.h" 25#include "includes.h"
26 26
27RCSID("$OpenBSD: sftp.c,v 1.13 2001/04/08 20:52:55 deraadt Exp $"); 27RCSID("$OpenBSD: sftp.c,v 1.14 2001/04/12 23:17:54 mouring Exp $");
28 28
29/* XXX: commandline mode */ 29/* XXX: commandline mode */
30/* XXX: copy between two remote hosts (commandline) */ 30/* XXX: copy between two remote hosts (commandline) */
@@ -147,7 +147,7 @@ make_ssh_args(char *add_arg)
147void 147void
148usage(void) 148usage(void)
149{ 149{
150 fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host\n"); 150 fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host[:file [file]]\n");
151 exit(1); 151 exit(1);
152} 152}
153 153
@@ -156,7 +156,8 @@ main(int argc, char **argv)
156{ 156{
157 int in, out, ch, debug_level, compress_flag; 157 int in, out, ch, debug_level, compress_flag;
158 pid_t sshpid; 158 pid_t sshpid;
159 char *host, *userhost; 159 char *file1 = NULL;
160 char *host, *userhost, *cp, *file2;
160 LogLevel ll; 161 LogLevel ll;
161 extern int optind; 162 extern int optind;
162 extern char *optarg; 163 extern char *optarg;
@@ -202,22 +203,27 @@ main(int argc, char **argv)
202 } 203 }
203 } 204 }
204 205
205 if (optind == argc || argc > (optind + 1)) 206 if (optind == argc || argc > (optind + 2))
206 usage(); 207 usage();
207 208
208 userhost = xstrdup(argv[optind]); 209 userhost = xstrdup(argv[optind]);
210 file2 = argv[optind+1];
211
212 if ((cp = strchr(userhost, ':')) != NULL) {
213 *cp++ = '\0';
214 file1 = cp;
215 }
209 216
210 if ((host = strchr(userhost, '@')) == NULL) 217 if ((host = strchr(userhost, '@')) == NULL)
211 host = userhost; 218 host = userhost;
212 else { 219 else {
213 *host = '\0'; 220 *host++ = '\0';
214 if (!userhost[0]) { 221 if (!userhost[0]) {
215 fprintf(stderr, "Missing username\n"); 222 fprintf(stderr, "Missing username\n");
216 usage(); 223 usage();
217 } 224 }
218 make_ssh_args("-l"); 225 make_ssh_args("-l");
219 make_ssh_args(userhost); 226 make_ssh_args(userhost);
220 host++;
221 } 227 }
222 228
223 if (!*host) { 229 if (!*host) {
@@ -256,7 +262,7 @@ main(int argc, char **argv)
256 262
257 connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid); 263 connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid);
258 264
259 interactive_loop(in, out); 265 interactive_loop(in, out, file1, file2);
260 266
261#if !defined(USE_PIPES) 267#if !defined(USE_PIPES)
262 shutdown(in, SHUT_RDWR); 268 shutdown(in, SHUT_RDWR);