How to get the date of the file stored/created in the remote system to my Talend job using ftp

Six Stars

How to get the date of the file stored/created in the remote system to my Talend job using ftp

Hello,

 

So I have a talend job that takes files from a remote file system and transfers the files from the remote directory using tFTPFileList and tFTPGET to hbase. However, I need to collect the date of the file created or initially stored in the remote file system as:

 

Capture3.PNG

Basically, I need the Jun 25 09:06 date of the file created from my remote file system and transferred to my talend along with

my file using tFTPGET.  I can get the file but I do not know how to transfer the date of the file. Please do tell me how I can go about this as soon as you can!

 

Thanks in advance!


Accepted Solutions
Six Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

Nevermind I solved, I have to use the filepath instead of the filename. That was a silly mistake.

Ten Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

sorry for my misunderstanding.
tJava , write java code:

context.filename = <ctrl+space tFTPFilelist current filename> ;

and in tSSH, change it into:

"date -r " +context.filename+ " %m-%d-%Y"

 




All Replies
Ten Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

tFTPFileProperties ... not 100% sure, never used it.
Six Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

So I am trying with tSSH by trying to run the command: "date - r context.filename %m-%d-%Y" by inputting this command in the command box in the tSSH component however I get ./filename not a directory when I run the job. Would you know how I can get the filename/value, stored in context.filename, inputted in place of the context.filename in the command above?

Ten Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

the global variable of the component tSSH is STDOUT: ( the standard execution output of the remote command) https://help.talend.com/reader/iYcvdknuprDzYycT3WRU8w/bDVRFxLbXmpSPgTICuqd3A
tSSH -> onComponentOk -> tJava -> System.out.println( <use your keyboard ctrl+space tSSH STDOUT> );
Six Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

Sorry for the misunderstanding. So I did whatever you mentioned in your response, my problem is:

I am getting the file and its filename from FTPFileList and FTPGet. The filename is later stored context.filename. Now I am connecting back to my remote filesystem using tSSH and am trying to run the command "date -r context.filename %m-%d-%Y" and inputting this command in the command box of tSSH, in hopes that when the job runs, the command is executed in remote filesystem linux environment and I get back the output of the date. I know how to print out the date but what I do not know how to input the actual filename in place of context.filename in the command. i.e. say my context.filename = parse.xml. I want to run the command:  "date -r parse.xml %m-%d-%Y" in the remote linux environment to get the date I need. In doing so, I run this instead:  "date -r context.filename %m-%d-%Y", but I am getting either ./filename does not exist or null values. How can I go about fixing this.

 

Thanks

Six Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

Nevermind I solved, I have to use the filepath instead of the filename. That was a silly mistake.

Ten Stars

Re: How to get the date of the file stored/created in the remote system to my Talend job using ftp

sorry for my misunderstanding.
tJava , write java code:

context.filename = <ctrl+space tFTPFilelist current filename> ;

and in tSSH, change it into:

"date -r " +context.filename+ " %m-%d-%Y"