Link to home
Start Free TrialLog in
Avatar of Jasmine Sandlas
Jasmine SandlasFlag for Oman

asked on

FTP Error | Connection Timed Out | Please HELP

I need to connect to FTP server through Command Prompt.

When I am trying to connect to it, it says Connection Timed Out.

D:\>ftp
ftp> open
To xyz.test.com
ftp: connect :Connection timed out
ftp>

What must be the reason behind it? Please help

I can connect to it through Filezilla.
Avatar of David Sankovsky
David Sankovsky
Flag of Israel image

Make sure that the server in question doesn't require a specific port.
Check your Filezilla settings, if you are connecting via a saved connection, it might override the default port.
also, when you said filezilla could connect properly, you checked it from the same computer from which you are trying the CLI approach right?
Avatar of Jasmine Sandlas

ASKER

Yes I checked it from the same computer on which I am trying to run through CMD.

How can I check if it requires a port or not?
Another way to determine if this is standard FTP would be to test with another application, like Putty (https://portableapps.com/apps/internet/putty_portable ).

If it fails, then there is most likely something non-standard on the FTP connection.

We are also assuming no firewall is blocking anything either on the computer or externally.
Ok fair enough.

is there a simple way to execute this in a batch script, means can we have a batch script in place where we can actually check for the folders in FTP server and get some of the files from there to our local directory.

Sorry for this silly question as I am still learning to write it.
Hi Jasmine.
For starters, if you are writing an automation script, might I suggest you do it using powershell rather than batch, it's much more robust, much better documented and is generally more suited for the task at hand.
I might be able to help you write the entire script, but I need some more information:

1) are you syncing entire folders or only files?
2) is the folder structure in your FTP server and the Destination identical
3) Do you have administrative access to the FTP server?
My FTP server is :- testftp.com
username:- Jasmine
Passsword :- Sandlas
port :- 22
------I can connect through WINSCP using the above credentials.

but, I want to do it through Batch script.

:Requirement:
I need to go to /Dev/test1/test2 location on FTP server and get all the files which are present on that particular folder to my Local directory

--No Powershell Please. Sorry

Please help. Thanks a lot in advance.

Waiting for it.......
Ah that was the missing piece.
Port 22 is not FTP, it's SSH.
Which can be utilized by filezilla,
I need to check if it can be done via CMD, I'll run some tests on my test box and get back to you.
If any other expert has an ready answer, please go ahead.
Okay Please. thanks,
I have winscp installed on my machine.
We can also try it by using winscp in our batch script.

Thanks a lot for all your help.
.....when I am trying to do

telnet testftp.com 21  --> it says connection timed out.
ASKER CERTIFIED SOLUTION
Avatar of David Sankovsky
David Sankovsky
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ERROR

D:\>test.bat
"Sync started"
< was unexpected at this time.
I found an error in my own code, this is the corrected version:
@echo off

echo "Sync started"

set backupDrive=e
set backupDirectory=\local\path

REM changing to the local directory for easier scripting
%backupDrive%:
cd %backupDirectory%

REM This is actual all one command, however separated to separate lines for readability
winscp.com /command ^
 "option batch abort" ^
 "option reconnecttime off" ^
 "open scp://jasmine:sandles@testftp.com:22 -rawsettings SendBuf=0 Compression=1 -timeout=999" ^
 "cd /Dev/test1/test2"^
 "get *"^
 "exit"
)

REM now back to C again
c:

REM exit

Open in new window

but I don't see "<" anywhere in my code, make sure you didn't accidentally throw an unused symbol somewhere in there
D:\>test.bat
"Sync started"
'winscp.com' is not recognized as an internal or external command,
operable program or batch file.
My winscp is present here:-

D:\Program Files\WinSCP\WinSCP.exe
do I need to mention something here:-

winscp.com /command ^

?
thanks it worked