SFTP batch mode patch

Jeremy Monin jdmossh at nand.net
Fri Feb 18 04:16:06 EST 2005


Hi,

We do a lot of automated file transfers with SFTP, and found this small 
patch very helpful.  The main effect is to tell the underlying SSH client 
that it's operating in batch mode.  Patch is against 3.9p1.

Thanks,
Jeremy Monin
Sysadmin and open-source developer

diff -ur openssh-3.9p1-orig\sftp.c openssh-3.9p1\sftp.c
--- openssh-3.9p1-orig\sftp.c	Sat Jul 17 02:12:08 2004
+++ openssh-3.9p1\sftp.c	Thu Oct 14 11:39:40 2004
@@ -1420,6 +1420,7 @@
 				fatal("%s (%s).", strerror(errno), optarg);
 			showprogress = 0;
 			batchmode = 1;
+			addargs(&args, "-obatchmode yes");
 			break;
 		case 'P':
 			sftp_direct = optarg;
diff -ur openssh-3.9p1-orig\sshconnect.c openssh-3.9p1\sshconnect.c
--- openssh-3.9p1-orig\sshconnect.c	Mon Jun 21 22:56:02 2004
+++ openssh-3.9p1\sshconnect.c	Thu Oct 14 09:02:32 2004
@@ -537,8 +537,11 @@
 	char *p;
 	int ret = -1;
 
-	if (options.batch_mode)
+	if (options.batch_mode) {
+		logit(prompt);
+		logit("Replied NO (batch mode)");
 		return 0;
+	}
 	for (msg = prompt;;msg = again) {
 		p = read_passphrase(msg, RP_ECHO);
 		if (p == NULL ||




More information about the openssh-unix-dev mailing list