File not found - Bash Script

Hi experts,

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.

Open in new window



Sample 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

Open in new window


Hope am clear with my requirements. Any help is greatly appreciated

Thank you
parpaaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
Try removing that "cd Test" line.
0
parpaaAuthor Commented:
Hi gerwinjansen

I tried removing cd Test but no luck :(
0
Gerwin Jansen, EE MVETopic Advisor Commented:
Can you these steps manually and see where it fails:

cd /somefolder/$folder_name
file1_To_Copy=`ls -tr *"$keyword1"*."$ftype" | tail -n 1`
echo ${file1_To_Copy}
sftp host@abc.com
cd Test
!ls -l
put ${file1_To_Copy}

Note the 2 commands in bold above, can you show output of those commands?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

parpaaAuthor Commented:
Hi gerwinjansen,

Apologies, the file was not present in the local working directory - Hence it was file was not found. Thank you so looking into this issue.

It has been resolved.
thank you
0
parpaaAuthor Commented:
thank you for your help
0
Gerwin Jansen, EE MVETopic Advisor Commented:
You're welcome ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.