I want to run a batch file which can connect automatically to SFTP Server running on Linux and can download files from Linux remote side to my local side. Besides that, this file will be scheduled to run automatically on every month. But, I'm facing a problem to connect it automatically? Below is one of my example of testing it:

set username=micro
set password=test
set r_dir=/home/micro/output
set l_dir=c:/temp
set filename=CDR-2005-05.csv
set tempSftpScript=script.batch

echo user %username%_%password%>>%tempSftpScript%
echo cd %r_dir%>>%tempSftpScript%
echo lcd %l_dir%>>%tempSftpScript%
echo get %filename%>>%tempSftpScript%
rem echo bye>>%tempSftpScript%

CALL c:\cygwin\bin\sftp.exe -b:%tempSftpScript% micro@url.com

if I just run the following code:

CALL c:\cygwin\bin\sftp.exe macrolynx@url.com

Then, it can connect automatically but also need to enter password manually.


Is there any way to connect to SFTP and download file automatically from Linux?


Your reply will be appreciated.

Thank You in advance,
Teing

You could write a shell script and have it run via the cron :)

To: Zachery

Thank you for your reply and suggestion. You suggested to write shell scripts & run it via the cron job.

For your information, I have no access permission to the remote server Linux to create cron job due to the server is from the other party. But my task is just want to access to the server and download an csv file to my local side.

I am using windows platform, can i do all this task and run it by shell script?

I'm not very good at Linux, or is it possible to run by batch files?

And, Because of the schedule task is same as cron job, I just think to run the schedule task which will run the shell script/batch file.


Pls: is it possible to give me sample of program which can perform this tasks?


Thanks very much & Apologize for all the disturb & mistake that I have done.

Teing

I am trying to setup the same process and having the same issue! Have you discovered a solution?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.