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
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