Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to give dynamic name for destination file using FTP

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
rammraju

New User


Joined: 05 Mar 2005
Posts: 65
Location: Hyderabad

PostPosted: Wed Dec 31, 2008 7:25 am    Post subject: How to give dynamic name for destination file using FTP
Reply with quote

Hi all,
I have a requirement where I have to FTP a file from mainframe to windows daily. The source is a GDG generation and the destination should be something like this "FileYYYYMM" where "YYYY" is current year, "MM" is current month and "DD" is current day.

After some research in google I could write the below script to prepare the destination file name which has the dynamic date in it, now I am not able to use this variable in the ftp GET command. Can some one help me on this.

Code:
@echo off&SETLOCAL

FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date

:s_fixdate
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
    set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof

:s_print_the_date
echo Month:[%mm%]  Day:[%dd%]  Year:[%yy%]
ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%

SET FileName=file

FOR %%Y IN (%YY%)   DO SET FileName=%FileName%%%Y
FOR %%Z IN (%MM%)   DO SET FileName=%FileName%%%Z
FOR %%X IN (%DD%)   DO SET FileName=%FileName%%%X

ftp -s:ftpMFtoWN.txt test.mainframe.com


The ftpMFtoWN.txt is something like this

Code:
Username
pwd
get 'TEST.ABCD.FILE(0)'  filename
bye
Back to top
View user's profile Send private message

Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2061
Location: Silicon Valley

PostPosted: Wed Dec 31, 2008 7:45 am    Post subject: Reply to: How to give dynamic name for destination file usin
Reply with quote

Not sure what this has to do with TSO/ISPF...

It looks like you are determining what the file name should be, but not doing anything with it. You need to re-create the ftpMFtoWN.txt file each time. And use the actual file name instead of the text of 'filename'
Back to top
View user's profile Send private message
rammraju

New User


Joined: 05 Mar 2005
Posts: 65
Location: Hyderabad

PostPosted: Wed Dec 31, 2008 9:19 am    Post subject: Reply to: How to give dynamic name for destination file usin
Reply with quote

Thanks for the reply...Never mind me posting it here

I just figured out the answer. This will do what I wanted

Code:
@echo off&SETLOCAL

FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date

:s_fixdate

IF "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof

:s_print_the_date

ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%

FOR %%Y IN (%YY%)   DO SET CurrDate=%CurrDate%%%Y
FOR %%Z IN (%MM%)   DO SET CurrDate=%CurrDate%%%Z
FOR %%X IN (%DD%)   DO SET CurrDate=%CurrDate%%%X

ECHO userid >> dynamic_file.txt
ECHO pwd >> dynamic_file.txt
ECHO GET ''TEST.ABCD.FILE(0)' File-%CurrDate%.txt >> dynamic_file.txt
ECHO quit >> dynamic_file.txt

ftp -s:dynamic_file.txt test.mainframe.com 

DEL dynamic_file.txt
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us