Upload files from windows location to Unix FTP server location


  I have a windows server 2012, where the location "D:\BR_Reports\FTP_Files\Test" will get a file with a filename that changes every day.
I'm trying to upload this file to an FTP location, "app/BR/EntPrs/Adhocs".
But when i save the below code as a bat file, and invoke it through Winscp, it's not uploading the file.
Can someone kindly help me resolve this issue?

option batch abort
option confirm off
echo off
open sftp://Buser_Name:B_Password@ -hostkey="ssh-rsa 1024 

option transfer ascii
PUT    'D:\BR_Reports\FTP_Files\Test\*.txt'                 

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Tom CieslikIT EngineerCommented:
Try this
LCD D:\BR_Reports\FTP_Files\Test\
PUT    *.txt /app/BR/EntPrs/Adhocs/*.TXT

Or if is not works

Try this
CD /app/BR/EntPrs/Adhocs
LCD D:\BR_Reports\FTP_Files\Test\
PUT    *.txt

I assume /APP is your root folder, if not use full path from Home to Adhocs   - like   /home/......./Adhocs
pvsbandiAuthor Commented:
Sorry, didn't work. Didn't do anything, when i ran the bat file.
My bat file has this command, pointing to the file "WinSCP_FTP.txt", which has the content from my original post.
"C:\Program Files (x86)\WinSCP\WinSCP.com" -D:\BR_Reports\FTP_Files\WinSCP_FTP.txt

Open in new window

Any other pointers?
Tom CieslikIT EngineerCommented:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /command /script=D:\BR_Reports\FTP_Files\WinSCP_FTP.txt
and use your own txt file.

Try run WinSCP and put commands manually.
Then you'll get error if there is something missing.
It will be much better to find the problem.

If you do then you can modify WinSCP_FPT.txt file

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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

pvsbandiAuthor Commented:
Thank you!
   It is now throwing the error "Host D: doesn't exist"
I guess, it's not able to navigate from C:\ to invoke D:\
Can someone help me overcome this issue?
pvsbandiAuthor Commented:
Thank you! your suggestion led me to the solution.
pvsbandiAuthor Commented:
Host D doesnt exist issue was because there was a space between = and D
Tom CieslikIT EngineerCommented:
You are very welcome :)
pvsbandiAuthor Commented:
May I ask a little follow up question?
How to invoke this script in a silent mode? It is opening the dos window every time.
Tom CieslikIT EngineerCommented:
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

From novice to tech pro — start learning today.