blob: 41011549bc40faeac7c41720c26579b09be9f85b [file] [log] [blame]
Darren Tucker59d928d2013-05-17 15:32:29 +10001# $OpenBSD: sftp-batch.sh,v 1.5 2013/05/17 04:29:14 dtucker Exp $
Damien Miller8b9cde72003-01-22 17:53:16 +11002# Placed in the Public Domain.
3
4tid="sftp batchfile"
5
Darren Tucker46662bf2004-01-30 13:02:55 +11006BATCH=${OBJ}/sftp.bb
Damien Miller8b9cde72003-01-22 17:53:16 +11007
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"
Darren Tuckered6b0c52009-10-07 10:43:57 +110038${SFTP} -b ${BATCH}.pass.1 -D ${SFTPSERVER} >/dev/null 2>&1 \
Damien Miller8b9cde72003-01-22 17:53:16 +110039 || fail "good commands failed"
40
41verbose "$tid: bad commands"
Darren Tuckered6b0c52009-10-07 10:43:57 +110042${SFTP} -b ${BATCH}.fail.1 -D ${SFTPSERVER} >/dev/null 2>&1 \
Damien Miller8b9cde72003-01-22 17:53:16 +110043 && fail "bad commands succeeded"
44
45verbose "$tid: comments and blanks"
Darren Tuckered6b0c52009-10-07 10:43:57 +110046${SFTP} -b ${BATCH}.pass.2 -D ${SFTPSERVER} >/dev/null 2>&1 \
Damien Miller8b9cde72003-01-22 17:53:16 +110047 || fail "comments & blanks failed"
48
49verbose "$tid: junk command"
Darren Tuckered6b0c52009-10-07 10:43:57 +110050${SFTP} -b ${BATCH}.fail.2 -D ${SFTPSERVER} >/dev/null 2>&1 \
Damien Miller8b9cde72003-01-22 17:53:16 +110051 && fail "junk command succeeded"
52
53rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.*
54
55