SCP Failing - In Script

I create a file that may contain several full path name files on a remote Linux that are to be copied. This file, called AWKOUTPUT is created from another script.
It contains:

X/picture1.png

The script is very simple
-------------------------------------------

REMOTEDIR="/var/CC/Stuff"
for i in `cat AWKOUTPUT`
 do
  echo $i
 scp user1@host:$REMOTEDIR/$i ./
done

--------------------------------------------
The scp fails indicating the file doesn't exist.
If I run scp manually it works fine, so the file does exist.
If I change the script to

--------------------------------------------

FILE="/var/CC/Stuff/X/picture1.png"
scp user1@host:$FILE ./

----------------------------------------------

it works fine.

If I add the -v option to scp the debug output cmd sent looks fine

debug1: Sending command: scp -v -f /var/CC/Stuff/X/Picture1.png
Sending file modes: C0644 739478 Picture1.png

Any suggestions ?

Try this and see what it returns:

REMOTEDIR="/var/CC/Stuff"
while read fname
do
	remoteFile="${REMOTEDIR}/${fname}"
	
	echo "remoteFile: [${remoteFile}]"
	
	echo "ls -l ${remoteFile}" | ssh -C -T -l <user> <host>
	scp -vvv <user>@<host>:${remoteFile} ./
done < AWKOUTPUT

Also, you should check this link: Useless Use of Cat Award

I hope it helps!

I tried your suggestion put still get the error on the scp that the file is unknown or doesn't exist.
It seems that taking some type of redirection to create the remote filename variable causes the problem.

Can you post the output of the script (-vvv, ssh debug)? Also, what is the source OS?

I can't understand why it is not working, I use it for a long time without problems!

Source system is Max OSX 10.6.8
I will try to post the output later.

Thanks