Page 1 of 1

Cp command in execute command stage

Posted: Mon Mar 28, 2011 6:10 pm
by SwathiCh
Hi,

Iam trying to copy latest file in a directory to the other using the below command .My DirPath1 may also contain subdirectory, so i used grep .

cp `ls -ltr #$DirPath1 | grep ^- | tail -1 | awk '{print $9}'` #$dirPath2#/.

This command works fine in putty but donot in datstage.

In the log i could see the below error message
Output from command ====>
cp: omitting directory `DirPath1'
cp: cannot stat `xyz.CSV': No such file or directory.

So ,can anyone help me out how to use this in execute comman stage.

Posted: Mon Mar 28, 2011 7:21 pm
by ray.wurlod
You may need to "escape" the single-quote characters.

Posted: Thu Mar 31, 2011 7:02 am
by premupdate

cp `ls -ltr #$DirPath1 | grep ^- | tail -1 | awk '{print $9}'` #$dirPath2#/

$DirPath1 is missing the right # symbol.

Posted: Thu Mar 31, 2011 3:21 pm
by ray.wurlod
Put the cp into the Command field and everything else into the Parameters field. Job parameters can not be resolved in the Command field.