Rename file while using SFTP to append date

12,773

Solution 1

The commands are being sent via JCL control card. I don't think this approach will work.

Solution 2

Since sftp isn't running a shell, there's nothing to execute the date command. You're probably going to have to evaluate the new name you want on the sender's side, and then execute the sftp rename.

Another option is to send the files into a queue area (like a folder with your date string), and have a script on the linux box move/rename the received files accordingly.

Share:
12,773
Hogstrom
Author by

Hogstrom

Long time IT guy with most of my career spent administering or developing solutions on multiple platforms. Most of my experience is on IBM Z (z/OS and z/VM) as well as Linux (multiple hardware architectures) and Mac OS X (been a fanboy since 2005 before Mac was cool). I enjoy making things work well and intuitively. Outside of work I like to make things and dabble in CNC machining (I own a Tormach PCNC1100, design, build and repair electronics and I love hunting big game and target shooting. Married for 25 years, father to 70 kids (been a foster parent for 22 years) and papa to 5 adopted kids.

Updated on June 05, 2022

Comments

  • Hogstrom
    Hogstrom almost 2 years

    I'm sending a file from a z/OS system to a Linux ftp sever using sftp.

    I want to append the date to the filename once the file resides on the linux box. (Ex: filename.txt becomes filename122308.txt)

    I have tried the 'rename' command using 'date +%m%d%y' - the file was renamed but the flags were not executed (The filename became filename'date +%m%d%y'.txt

    The 'cp' and 'mv' commands do not work... any ideas?

    Thanks.

  • Admin
    Admin over 15 years
    The commands are being sent via JCL control card. I don't think this approach will work.
  • Alfredo Hu
    Alfredo Hu over 15 years
    How are you submitting the commands in JCL? Are you executing a shell command from the JCL via the BPX* commands?