Continuation character for sftp commands using DTLSPAWN
-
- Posts: 22
- Joined: Thu Apr 16, 2009 8:26 am
Continuation character for sftp commands using DTLSPAWN
In FTP we could use a '+' as continuation character on the 80 byte long input record when doing commands such as put/get/rename etc. What is the equivalent for SFTP (DTLSPAWN)?
-
- Posts: 39
- Joined: Wed Feb 11, 2009 10:23 am
Re: Continuation character for sftp commands using DTLSPAWN
Problem with using the back slash as a continuation character
- Worked on the ls command
- Did not work as expected on the put command
JCL submitted:
//SFTPRUN1 EXEC COZBATCH,COND=(4,LT)
//STDIN DD *
- - - - - - - - - - - - - -
export SFTP_ZOS_OPTIONS="nosmf"
#ssh_opts="-oBatchMode=no"
ls /u/magee/\
.ssh
cozsftp $ssh_opts -b- $tgtuser@$tgthost
put //MAGEE.SEQ.ERRLIST\
//MAGEE.SEQ.ERRLIST1 <== Note: there are actually 4 blanks at the beginning of this record
quit
Output:
authorized_keys
id_rsa
id_rsa.pub
known_hosts
cozsftp> put //MAGEE.SEQ.ERRLIST\
Uploading //MAGEE.SEQ.ERRLIST to /u/magee/MAGEE.SEQ.ERRLIST
cozsftp> //MAGEE.SEQ.ERRLIST1
Co:Z SFTP version: 1.8.0 (5.0p1) 2011-02-03
Copyright (C) Dovetailed Technologies, LLC. 2008. All rights reserved.
ZosDataset: Opening dataset MAGEE.SEQ.ERRLIST for read with options: shr
ZosDataset: Closing dataset //MAGEE.SEQ.ERRLIST - 17 records read, 1085 bytes
[88.747] Invalid command.
Is this corrected in a later release ??
- Worked on the ls command
- Did not work as expected on the put command
JCL submitted:
//SFTPRUN1 EXEC COZBATCH,COND=(4,LT)
//STDIN DD *
- - - - - - - - - - - - - -
export SFTP_ZOS_OPTIONS="nosmf"
#ssh_opts="-oBatchMode=no"
ls /u/magee/\
.ssh
cozsftp $ssh_opts -b- $tgtuser@$tgthost
put //MAGEE.SEQ.ERRLIST\
//MAGEE.SEQ.ERRLIST1 <== Note: there are actually 4 blanks at the beginning of this record
quit
Output:
authorized_keys
id_rsa
id_rsa.pub
known_hosts
cozsftp> put //MAGEE.SEQ.ERRLIST\
Uploading //MAGEE.SEQ.ERRLIST to /u/magee/MAGEE.SEQ.ERRLIST
cozsftp> //MAGEE.SEQ.ERRLIST1
Co:Z SFTP version: 1.8.0 (5.0p1) 2011-02-03
Copyright (C) Dovetailed Technologies, LLC. 2008. All rights reserved.
ZosDataset: Opening dataset MAGEE.SEQ.ERRLIST for read with options: shr
ZosDataset: Closing dataset //MAGEE.SEQ.ERRLIST - 17 records read, 1085 bytes
[88.747] Invalid command.
Is this corrected in a later release ??
David
Re: Continuation character for sftp commands using DTLSPAWN
The back slash is a *shell* continuation character. So, if you have a shell script (running under /bin/sh via COZBATCH), the backslash will work as a continuation character.
The problem with your example is that you have this:
When you do this and run the cozsftp command, it is doing the I/O from stdin and reading the next three lines (up until quit tells it to stop). The cozsftp command (like most Unix commands) do not provide their own continuation line support, which is why it doesn't work.
The solution to this is to put the input commands to the cozsftp command in a "here document", like this:
This is how our samples are done. With a shell "here document", the input up to EOB is read by the shell and therefore it will process variable substitutions and line continuations.
The problem with your example is that you have this:
Code: Select all
cozsftp $ssh_opts -b- $tgtuser@$tgthost
put //MAGEE.SEQ.ERRLIST\
//MAGEE.SEQ.ERRLIST1 <== Note: there are actually 4 blanks at the beginning of this record
quit
The solution to this is to put the input commands to the cozsftp command in a "here document", like this:
Code: Select all
cozsftp $ssh_opts -b- $tgtuser@$tgthost <<EOB
put //MAGEE.SEQ.ERRLIST\
//MAGEE.SEQ.ERRLIST1 <== Note: there are actually 4 blanks at the beginning of this record
quit
EOB
-
- Posts: 39
- Joined: Wed Feb 11, 2009 10:23 am
Re: Continuation character for sftp commands using DTLSPAWN
We are seeing a problem with an existing sftp server that now seems to want the target acct name to include the domain name in the format
domain\user-acct
Setting $tgtuser=domain\acct with that back slash character fails.
Is there a solution to this coding when using COZBAZTCH?
domain\user-acct
Setting $tgtuser=domain\acct with that back slash character fails.
Is there a solution to this coding when using COZBAZTCH?
David
Re: Continuation character for sftp commands using DTLSPAWN
The input to COZBATCH is a z/OS Unix shell script, so you have to watch out for shell meta-characters like '\' and following normal shell quoting rules.
It would be helpful if you could post an example of the input that you are having trouble with, so that we can be specific about suggesting how to quote it to avoid the backslash meta character.
It would be helpful if you could post an example of the input that you are having trouble with, so that we can be specific about suggesting how to quote it to avoid the backslash meta character.
-
- Posts: 39
- Joined: Wed Feb 11, 2009 10:23 am
Re: Continuation character for sftp commands using DTLSPAWN
I think my problem is with the back slash in the tgtuser variable below:
//SFTPRUN1 EXEC COZBATCH,COND=(4,LT)
//STDIN DD *
#PATH=/usr/lpp/coz/bin:$PATH
tgtuser=dds\riskftp
tgthost=my.sftp.server
- - - - - - - - - - - - - - - - - - 14 Line(s) not Display
#
cozsftp $ssh_opts -b- $tgtuser@$tgthost <<EOB
zopts mode=binary,lrecl=1024,recfm=fb,blksize=6144,space=cyl.800.400
put //MAGEE.SEQ.LONG.DATA.SET.NAME.FILE\
my.file.on.the.target.system
quit
EOB
David
Re: Continuation character for sftp commands using DTLSPAWN
Right, in order for the backslash to no be treated as a shell meta character, you would need to quote it:
Code: Select all
tgtuser='dds\riskftp'
-
- Posts: 1
- Joined: Thu May 08, 2014 10:14 pm
Re: Continuation character for sftp commands using DTLSPAWN
I forgot those command. How can i get them back?LeonBylsma wrote:In FTP we could use a '+' as continuation character on the 80 byte long input record when doing commands such as put/get/rename etc. What is the equivalent for SFTP e cig (DTLSPAWN)?