ssh - rm failing

Hi,
Please help me...
I am creating a string of filenames with absolute path and deleting those files situated in the remote server using ssh .. but it doesnot work..
Can anyone help me...
here is my code

for FileName in $\{myDire\}
do
        Tmp=\`basename $FileName\`
        DelFiles="$\{DelFiles\} "$\{SourceDirectory\}/$\{Tmp\}
done

#DelFiles contain files to be deleted with abolute path

ssh USer/Pwd@Domain echo ${DelFiles} | xargs rm

This statement gives 0 as the return value , but not deleting any of those files

Thanks in advance
Shihab

What is happening here is that your '|' is being interpreted by the local shell. This works just like rsh (read the man page for details about this.. the first few lines explain this). Try running the command escaping the '|'. i.e.

for FileName in ${myDire}
do
Tmp=`basename $FileName`
DelFiles="${DelFiles} "${SourceDirectory}/${Tmp}
done
#DelFiles contain files to be deleted with abolute path

ssh USer/Pwd@Domain echo ${DelFiles} \| xargs rm

Thanks a lot blowtorch...
It worked !!!!

But a small problem..
I have to give complete path to xargs...
why is it like that ?
ssh USer/Pwd@Domain echo ${DelFiles} \| /bin/xargs /bin/rm

any idea?

Shihab

If you have to supply full path, that is because the PATH variable does not have the required directories. Try running the following command:

ssh user@domain echo $PATH

Another thing, why are you doing an echo and piping the output to xargs, wont just /bin/rm ${DelFiles} do the job as well?

The PATH is set properly
an I am able to execute the same command without absolute path from the server

Actually why I did is , the number of arguments to rm will be more.. so it was giving error
so the final command is like this

ssh USer/Pwd@Domain echo ${DelFiles} \| /bin/xargs -n 20 /bin/rm

Shihab