summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-03-07 01:26:48 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-03-07 01:26:48 +0000
commit562c26bccf50264bb10551d81cb5cce93c2e8d6f (patch)
treeba7fdf542c230443df323855a113154b1cb4ffb3 /sftp.c
parente21c4adaac7eae7b66b731defc2172a6a80a79ef (diff)
- deraadt@cvs.openbsd.org 2001/03/06 06:11:44
[sftp-int.c sftp.1 sftp.c] sftp -b batchfile; mouring@etoh.eviladmin.org
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sftp.c b/sftp.c
index f24f7507..c2282509 100644
--- a/sftp.c
+++ b/sftp.c
@@ -24,7 +24,7 @@
#include "includes.h"
-RCSID("$OpenBSD: sftp.c,v 1.9 2001/03/03 23:52:22 markus Exp $");
+RCSID("$OpenBSD: sftp.c,v 1.10 2001/03/06 06:11:44 deraadt Exp $");
/* XXX: commandline mode */
/* XXX: copy between two remote hosts (commandline) */
@@ -49,6 +49,7 @@ char *__progname;
int use_ssh1 = 0;
char *ssh_program = _PATH_SSH_PROGRAM;
char *sftp_server = NULL;
+FILE* infile;
void
connect_to_server(char **args, int *in, int *out, pid_t *sshpid)
@@ -146,7 +147,7 @@ make_ssh_args(char *add_arg)
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);
}
@@ -161,9 +162,10 @@ main(int argc, char **argv)
extern char *optarg;
__progname = get_progname(argv[0]);
+ infile = stdin; /* Read from STDIN unless changed by -b */
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) {
case 'C':
compress_flag = 1;
@@ -186,6 +188,14 @@ main(int argc, char **argv)
case 'S':
ssh_program = optarg;
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':
default:
usage();
@@ -257,6 +267,8 @@ main(int argc, char **argv)
close(in);
close(out);
+ if (infile != stdin)
+ fclose(infile);
if (waitpid(sshpid, NULL, 0) == -1)
fatal("Couldn't wait for ssh process: %s", strerror(errno));