SFTP Rename file to append date?

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

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.

The options exists to execute sftp as... sftp user@host:file file ...so you might execute... export WHEN=`date +%m%d%y` sftp theUser@theHost:filename$WHEN. Txt filename.Txt.

The commands are being sent via JCL control card. I don't think this approach will work. – Chad Dec 23 '08 at 17:16.

In that case you could just rename the files there. You could for instance use inotify to monitor the directory, and then have a script that adds the date to files whenever a new file is created in that directory. Here's a simple example in Python (although there are inotify bindings for most languages).

The event you'll want to listen for is IN_CREATE.

Establish a local variable to store the LOGINID to be used export USERID=xxxxx #Establish a local variable to store the Path/file location on Remote machine export REMOTEPATH=/some/path/ #Establish a local variable to store the NAME of the remote Server export TARGET=192.168.0. Xx #Establish a local variable to store the new component of the file name (in #this case, a modification of Date) export WHEN=`date +%m%d%y` #Demonstrate that the USERID variable is set properly by echoing it out to the #StandardOut echo "User "$USERID #Demonstrate that the TARGET variable is set properly by echoing it out to the #StandardOut echo "Target Server: "$TARGET #Demonstrate that the REMOTEPATH / server variable is set properly by echoing #it out to the StandardOut echo "Target Path "$REMOTEPATH #Demonstrate that the WHEN / date name modication variable is set properly by #echoing it out to the StandardOut echo "Date component of file "$WHEN #Just echo out that we're about to do something useful echo "Sending file to REMOTE" #Simulate the user typing out a command by using the "echo" command. We use #the $REMOTEPATH and $WHEN variables to modify "what the user types" but when #we're done, echo passes information into SFTP just like the user were sitting #there typing in the #commands.In this case, it should send in #"put /local/path/file /some/path/fileName09092009.

Txt" #That is provided as the command list to sftp because of the single "-" that #says "get my list of commands from standard-input" The -vvv is for verbose #(lots of diagnostics) and then the $USERID@$TARGET uses the USERID and TARGET #variables to connect as user-at-server for the exchange. #A passwordless SSH authentication is already in place, so no password #is needed. Echo "put /local/path/file $REMOTEPATH/fileName$WHEN.

Txt " | \ sftp -b - -vvv $USERID@$TARGET #Just echo out that we're about to do the next step and change file #permissions. Echo "Changing file Permissions on REMOTE" echo "Done.

Not sure about your mainframe SFTP client but many SFTP clients support using the! Prefix to run local operating system commands. So you can copy the file to the new name before sending, then send, then remove the copy.E.g.

:! Cp filename. Txt filename122308.

Txt put filename122308. Txt! Rm filename122308.

Txt exit If space is a premium, use mv twice instead of cp & rm.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions