Page 1 of 4

Delete file after FTP

Posted: Thu Apr 13, 2006 10:41 am
by srimitta
Hi,

I have a job which pulls data from unix box using DataSatge ftp stage, and on sucessful run I need to delete source file.

Source file is on different Unix box and my DataStage server is on different Unix box.

Any thoughts........

Thanks
Mitta

Re: Delete file after FTP

Posted: Thu Apr 13, 2006 10:51 am
by ogmios
One of the reasons I never use ftp stage but always shell out to get the file via an OS script. What you want to do is not in the ftp file stage.

Ogmios

Posted: Thu Apr 13, 2006 10:52 am
by diamondabhi
srimitta,
Write a unix script to delete the file and execute it as an after job routine(ExecSH).

Thanks,
Abhi.

Posted: Thu Apr 13, 2006 10:56 am
by srimitta
If my source file is in same server I can do that, but it is on different server.

I know how to do it on same server......

Posted: Thu Apr 13, 2006 10:57 am
by chulett
Actually, you can do things like this via the FTP stage. Check out the 'Telnet Before' and 'Telnet After' options on the Input / Properties tab. (Scroll way down)

Or just use a shell script instead of the stage. :wink:

Posted: Thu Apr 13, 2006 11:04 am
by srimitta
Hey Chulett....Thanks for quick response

Can I use command rm <file name> in 'Telnet After', will this serve my purpose.

Posted: Thu Apr 13, 2006 11:04 am
by diamondabhi
I believe if you have the right access u can write a script from ur unix box to ftp into the remote server and delete command will delete the rquired file, I am using it. Please correct me if I am wrong.

Thanks,
Abhi

Posted: Thu Apr 13, 2006 11:06 am
by diamondabhi
Craig,
Thanks, telnet after seems to be a better option.

Posted: Thu Apr 13, 2006 11:22 am
by chulett
srimitta wrote:Can I use command rm <file name> in 'Telnet After', will this serve my purpose.
Possibly, depending on permissions and such. Give it a shot and see.

Make sure you've got all of the Telnet Prompts setup correctly in the stage so it can logon properly after the ftp is complete.

Posted: Thu Apr 13, 2006 11:45 am
by srimitta
Hi Chulett,

In stage > Properties I have given userid and pwd
'Telnet Prompt1' <User Id>
'Telnet Prompt2' <Password>

In Output > Properties I have givn
rm test

DS job ran sucessfully but it wrote warning to log

unable to execute Telnet command 'Telnet After Command'/b]

I think Iam missing some other inputs in FTP stage....Any input........

Thanks
Mitta

Posted: Thu Apr 13, 2006 11:47 am
by srimitta
My source Unix box doesn't support coldfusion........anything to do with this.

Posted: Thu Apr 13, 2006 12:12 pm
by chulett
Coldfusion? Not sure what that would have to do with anything. :?

If you aren't sure what's going on, change the Link Tracing Level property from its default of zero to something else so it can tell you what the problem is. With your cursor in the field, click on Property Help to see what values can go there.

Then run the job again and hopefully enough information will be in the log such that you can figure out what your issue is.

Posted: Thu Apr 13, 2006 12:13 pm
by srimitta
Thanks....Chulett,

your tip helped me, now Iam able to read file, archive file and delete file using DataStage ftp stage.

Posted: Thu Apr 13, 2006 12:18 pm
by chulett
Excellent! :D

Posted: Wed Feb 27, 2008 9:10 pm
by nkln@you
Hi All,

Even I am trying the same approach. I am ftping a file from one server to another server and when the ftp completes, want to delete the old file present. So I am using ftp stage and the ftp is happening perfectly but the removal of file is not happening. Its giving the error Bytes returned from 'tnet_recv() : 0 . But as per the trace log, its able to connect to the telnet socket. After that its giving "Looking for Telnet prompt number 1" and then after 1 min, it gives the above warning and aborts. Please suggest what to do.