"Execute Command" stage in sequencer

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

"Execute Command" stage in sequencer

Post by Marley777 »

Hi, thanks for reading.

Anyone know how to use this command in a "execute command" stage within a sequencer. Want to get the command to work then replace -print with delete so I can delete all empty files.

cd /directory_name|find . ! -size 0 -print

tried using 'cd' as the command and '/DStage_workfiles/iiwdev/Rejects|find . ! -size 0 -print' as the parameters. But it printed files from a different directory. Not results I expected. Any help is greatly appreciated.

here is the output

SeqRich_ErrFilesTest..JobControl (@cmdRemoveTriggerFile): Executed: cd /DStage_workfiles/iiwdev/Rejects|find . ! -size 0 -print
Reply=0
Output from command ====>
.
./&COMO&
./&COMO&/INSTALL
./&COMO&/PROJECT.UPGRAD
./&COMO&/PROJECT.UPGRAD/E
./&COMO&/SETUP.EXAMPLE1
./&COMO&/SETUP.EXAMPLE1/?
./&PH&
./&PH&/DSD.RUN_25405_15914_065632
./&PH&/DSD.RUN_26738_15927_242087
./&PH&/DSD.RUN_27493_15732_713615
./&PH&/DSD.RUN_28558_16020_018112
./&PH&/DSD.RUN_28773_15613_730682
./&PH&/DSD.RUN_28792_15591_553238
./&PH&/DSD.RUN_28807_15591_39


etc.....
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: "Execute Command" stage in sequencer

Post by SURA »

Why do you want to change the directory and then execute the command?

Try to use it as a single command like below.

find FILEPATH ! -size 0 -print

DS User
PaulVL
Premium Member
Premium Member
Posts: 1315
Joined: Fri Dec 17, 2010 4:36 pm

Post by PaulVL »

A command Sequencer's default directory is your project directory. Should the CD fail, you will be in your project directory.

trust me... you do NOT want to blindly delete files assuming the CD worked.

Write a script, test the return code of the CD, or better yet, fully qualify the path of the files you wish to delete.

I have seen to many users write bad code like that and nuke their project directory.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

SURA's solution should be what you are actually looking for, following what you were doing, the correct way is to cd path && find . (etc)... this will mean the find is only executed if the cd was successful. what you were doing is piping the result of the cd to the find, which doesn't really mean much
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

cd doesn't have any output, so using a pipe on that output causes find to read nothing.

You probably meant to use ; or && rather than |.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Thanks to everyone for your response.

This worked for me

find FILEPATH ! -size 0 -print
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Marley777 wrote:This worked for me

find FILEPATH ! -size 0 -print
You have marked this resolved, but you risk causing unintended, perhaps serious problems, as PaulVL described.

I suggest you study the find command in detail before deleting.

As is, it will recursively search through all subdirectories beneath FILEPATH and identify all NON-empty files according to the -size 0 option you've used--it's not based on the file's actual byte size but rather the file's block size (file size rounded up to nearest block size).

Read the man page about the find command's option to determine the correct option.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Post Reply