Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I change filename using ftp local copyfile?

Status
Not open for further replies.

vizman

MIS
Apr 26, 2005
8
US
I am new to Procomm scripts and am working off an existing one. In part, this script copies a file from a PC to a UNIX BOX, using the following command:

ftp local copyfile "BARNES_XML_INV"

What I would LIKE to do is copy the file to UNIX with a DATE STAMP, like so "BARNES_XML_INV" + MMDDYYYY =

BARNES_XML_INV04262005.

Can this be done? thank you
 
Here is a way to do it:

proc main
string sFile
integer iDay, iMonth, iYear, iHour, iMin, iSec

strfmt sFile "BARNES_XML_INV_%02d%02d%d" iMonth iDay iYear
ftp local copyfile sFile
endproc

 
Thank you. But to clarify, the file on the PC side is called BARNES_XML_INV - and I want to take this file and COPY it to UNIX with the date appended. So I either need to RENAME the file and THEN send to UNIX -or- change the name as it is copied over. In your example, the file with the appended date does not exist. Is there a way to rename a file? thanks!
 
Oops, I knew I left something out. Actually, it looks like I left out even more than that now that I tested the script again. Try this:

proc main
string sNewFile
string sOldFile = "BARNES_XML_INV"
integer iDay, iMonth, iYear, iHour, iMin, iSec

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sNewFile "%s_%02d%02d%d" sOldFile iMonth iDay iYear
rename sOldFile sNewFile
ftp local copyfile sNewFile
endproc

Keep in mind that the example above assumes the file is in the ASPECT directory, otherwise you would need to fully qualify the filename when defining sOldFile.



 
That worked! Thanks!
So the outcome should be the following ,correct?

original filename
----------------------
BARNES_XML_INV

new filename
----------------------
BARNES_XML_INV_01012005


using the format(strfmt sNewFile "%s_%02d%02d%d" sOldFile iMonth iDay iYear)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top