how to use RENAME

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
fulldraw68
Posts: 10
Joined: Mon Oct 19, 2015 5:29 pm

how to use RENAME

Post by fulldraw68 »

Hello,
I am just starting to replace normal ftp with cozsftp. I have it working in several jobs and like it.
My question is exactly how to get the RENAME function working. Current ftp commands submitted in batch job look like...

Code: Select all

LOCSITE TRAIL                                                
CD  holdbox/batch/inbound                                           
PUT 'mainframe.fileabc'  fileabc.tmp                
REN fileabc.tmp filedef.txt 

I'm using cozsftp in batch like below...

Code: Select all

//SFTPIN DD *                                                    
pwdsn='*****'                                     
user=********                                            
host=************                                              
lzopts="mode=text"                                               
lfile=//DD:MYDD                                                  
rfile=/holdbox/batch/inbound/fileabc.tmp                              
                                                                 
sftp_opts="$sftp_opts -oPubkeyAuthentication=no"                 
                                                                 
. $script_dir/sftp_put.sh                                        

//MYDD  DD DSN=MAINFRAME.FILEABC,DISP=SHR
Where do I incorporate the RENAME?
One other question....exactly how do I continue the rfile to a second line if needed?

Thanks.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: how to use RENAME

Post by dovetail »

The sample script that you are using (sftp_put.sh) only does a put command.
If you want to do arbitrary commands, then you would use this:

Code: Select all

//SFTPIN DD *                                                    
pwdsn='*****'                                     
user=********                                            
host=************                                              
lzopts="mode=text"                                               
lfile=//DD:MYDD                                                  
rfile1=/holdbox/batch/inbound/fileabc.tmp                              
rfile2=/holdbox/batch/inbound/fileabc.data                             
                                                                 
sftp_opts="$sftp_opts -oPubkeyAuthentication=no"                 
                                                                 
. $script_dir/sftp_connect.sh << EOB
lzopts $lzopts
put $lfile $rfile1
rename $rfile1 $rfile2 
EOB

//MYDD  DD DSN=MAINFRAME.FILEABC,DISP=SHR
fulldraw68
Posts: 10
Joined: Mon Oct 19, 2015 5:29 pm

Re: how to use RENAME

Post by fulldraw68 »

Thanks. That is working great.
I am having an issue with the ls or dir commands. The pwd command appears to be working.
I'm not getting anything returned...

Code: Select all

. $script_dir/sftp_connect.sh << EOB
ls
pwd
dir
EOB
output from above....

Code: Select all

cozsftp> ls                    
cozsftp> pwd                   
Remote working directory: /    
cozsftp> dir      
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: how to use RENAME

Post by dovetail »

The Co:Z SFTP command and subcommands ("interactive commands") are documented here:

https://dovetail.com/docs/sftp/cozsftp_ref.html

there is also a "help" command.
there is no "dir" command
Post Reply