Guys
I have a datastage job to read a file(sales_20121112_0910.txt) from sftp remote server. I am using path/sales* in ftp stage(parallel job) and able to read data. But I need get exact file name to load into a table. also I need to move the same file to another folder in remote sever.
since I am not able to get the exact name of the file obviously not able to perform rename/move commands.
please advice.
Thanks
Read Name of a file in remote server SFTP
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3
- Joined: Thu May 17, 2007 4:47 pm
Re: Read Name of a file in remote server SFTP
Use External Source stage and run any unix command you want.
Source Method: Specific Program
Source program: ls path/sales*
add a column and it will contain list of filenames.
can use after job sub-routine to move files after processing.
Source Method: Specific Program
Source program: ls path/sales*
add a column and it will contain list of filenames.
can use after job sub-routine to move files after processing.
Re: Read Name of a file in remote server SFTP
I m not able to write multiple unix command in External stage. But
when I give sftp userid@remote.server is working.
Is it possbile to write ls -ltr result into an output. ??
when I give sftp userid@remote.server is working.
Is it possbile to write ls -ltr result into an output. ??
Sure, using redirection via the ">" or ">>" operators.
http://en.wikipedia.org/wiki/Redirection_%28Unix%29
http://en.wikipedia.org/wiki/Redirection_%28Unix%29
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Re: Read Name of a file in remote server SFTP
I am not sure of the issue: do you want to get the file name before you get the file, or after? Do you have access to the remote server via some way other than sftp? If you can get the file with a wildcard, but cannot list the results, you could try putting it in a local directory you know is empty (make a temporary directory for example and put it there) then list the files in that local directory - the only one should be your file. If you want to list the files before you get them, you could try using "ssh hostname ls path/sales*" you may introduce a race condition then. A previous post has already suggested putting the results in a text file for reading.
Brian Fennell
Brian Fennell