Upload files from windows location to Unix FTP server location

pvsbandi
pvsbandi used Ask the Experts™
on
Hi,

  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@1.1.3.131 -hostkey="ssh-rsa 1024 

60:19:e6:8c:f3:0b:e8:73:90:47:bc:78:a2:ca:c3:c6"
option transfer ascii
                   
PUT    'D:\BR_Reports\FTP_Files\Test\*.txt'                 
      	app/BR/EntPrs/Adhocs/*.TXT                 
close
exit

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Tom CieslikIT Engineer
Distinguished Expert 2017

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

Author

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?
IT Engineer
Distinguished Expert 2017
Commented:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /command /script=D:\BR_Reports\FTP_Files\WinSCP_FTP.txt
and use your own txt file.

Or
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
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

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?

Author

Commented:
Thank you! your suggestion led me to the solution.

Author

Commented:
Host D doesnt exist issue was because there was a space between = and D
Tom CieslikIT Engineer
Distinguished Expert 2017

Commented:
You are very welcome :)

Author

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 Engineer
Distinguished Expert 2017

Commented:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial