xref: /freebsd/crypto/openssh/regress/sftp-batch.sh (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
1#	$OpenBSD: sftp-batch.sh,v 1.5 2013/05/17 04:29:14 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="sftp batchfile"
5
6BATCH=${OBJ}/sftp.bb
7
8rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.*
9
10cat << EOF > ${BATCH}.pass.1
11	get $DATA $COPY
12	put ${COPY} ${COPY}.1
13	rm ${COPY}
14	-put ${COPY} ${COPY}.2
15EOF
16
17cat << EOF > ${BATCH}.pass.2
18	# This is a comment
19
20	# That was a blank line
21	ls
22EOF
23
24cat << EOF > ${BATCH}.fail.1
25	get $DATA $COPY
26	put ${COPY} ${COPY}.3
27	rm ${COPY}.*
28	# The next command should fail
29	put ${COPY}.3 ${COPY}.4
30EOF
31
32cat << EOF > ${BATCH}.fail.2
33	# The next command should fail
34	jajajajaja
35EOF
36
37verbose "$tid: good commands"
38${SFTP} -b ${BATCH}.pass.1 -D ${SFTPSERVER} >/dev/null 2>&1 \
39	|| fail "good commands failed"
40
41verbose "$tid: bad commands"
42${SFTP} -b ${BATCH}.fail.1 -D ${SFTPSERVER} >/dev/null 2>&1 \
43	&& fail "bad commands succeeded"
44
45verbose "$tid: comments and blanks"
46${SFTP} -b ${BATCH}.pass.2 -D ${SFTPSERVER} >/dev/null 2>&1 \
47	|| fail "comments & blanks failed"
48
49verbose "$tid: junk command"
50${SFTP} -b ${BATCH}.fail.2 -D ${SFTPSERVER} >/dev/null 2>&1 \
51	&& fail "junk command succeeded"
52
53rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.*
54
55
56