Delete file after FTP

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Delete file after FTP

Post 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
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Re: Delete file after FTP

Post 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
In theory there's no difference between theory and practice. In practice there is.
diamondabhi
Premium Member
Premium Member
Posts: 108
Joined: Sat Feb 05, 2005 6:52 pm
Location: US

Post by diamondabhi »

srimitta,
Write a unix script to delete the file and execute it as an after job routine(ExecSH).

Thanks,
Abhi.
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post 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......
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

Hey Chulett....Thanks for quick response

Can I use command rm <file name> in 'Telnet After', will this serve my purpose.
diamondabhi
Premium Member
Premium Member
Posts: 108
Joined: Sat Feb 05, 2005 6:52 pm
Location: US

Post 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
diamondabhi
Premium Member
Premium Member
Posts: 108
Joined: Sat Feb 05, 2005 6:52 pm
Location: US

Post by diamondabhi »

Craig,
Thanks, telnet after seems to be a better option.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post 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
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

My source Unix box doesn't support coldfusion........anything to do with this.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

Thanks....Chulett,

your tip helped me, now Iam able to read file, archive file and delete file using DataStage ftp stage.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent! :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
nkln@you
Premium Member
Premium Member
Posts: 271
Joined: Wed Nov 17, 2004 5:15 am
Location: US

Post 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.
Aim high
Post Reply