File Not found - Bash script

I'm facing issues in executing the bash script of mine. This script will pick the latest file received and connects SFTP server and files is placed on this remote server.
Error message

Enter password:
"File movement"
sftp> cd Test
sftp> put Test_File_201309.txt
File "Test_File_201309.txt" not found.

Portion of Code

cd /somefolder/$folder_name
file1_To_Copy=`ls -tr *"$keyword1"*."$ftype" | tail -n 1`


if [[ condition1 == condition2 ]]
then 
echo "File movement"
sftp host@abc.com <<EOF
cd Test
put ${file1_To_Copy}
EOF
fi

Any help is greatly appreaciated Thank you

Your output can't be correct. [[ condition1 == condition2 ]] can never be true.

(not to mention why Enter password: comes before "File movement", or even why "File movement" has quotes around it)

If you expect accurate help, you should provide accurate information.

Scott, Here is the output ..

File movement
connecting to host@abc.com..
Enter password: 
sftp> cd Test
sftp> put Test_File_201309.txt
File "Test_File_201309.txt" not found.

---------- Post updated at 08:18 AM ---------- Previous update was at 08:05 AM ----------

Also the if statement is something like this

if [[ a == b ]]

-- Apologies if am not clear with my requirements. Thank you

Check that your sftp is in the local directory you think it is ( lpwd )* and that the file does exist ( lls ). Also check you don't have any whitespace in the filename.

    • it should be in the current working directory, but I forget if you can configure sftp to start somewhere else by default.

Hi CarloM

Thank you so much for your response, Unfortunately bash scripting is very new to me. I dont know how to do the checks which you asked me to do :frowning: We dont have any whitespaces in file name

Thanks again

Just add them to the heredoc for your SFTP session:

sftp host@abc.com <<EOF
lpwd
lls
cd Test
put ${file1_To_Copy}
EOF

file is not available on local working directory. let me copy tat to local directory and will check ..

---------- Post updated at 03:05 PM ---------- Previous update was at 03:00 PM ----------

Thanks Carlo.. it worked.. Thank you so much