Page 1 of 1

"Execute Command" stage in sequencer

Posted: Thu Feb 09, 2012 4:37 pm
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.....

Re: "Execute Command" stage in sequencer

Posted: Thu Feb 09, 2012 4:50 pm
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

Posted: Thu Feb 09, 2012 4:51 pm
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.

Posted: Thu Feb 09, 2012 5:13 pm
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

Posted: Thu Feb 09, 2012 6:35 pm
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 |.

Posted: Fri Feb 10, 2012 7:21 am
by Marley777
Thanks to everyone for your response.

This worked for me

find FILEPATH ! -size 0 -print

Posted: Fri Feb 10, 2012 11:45 am
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.