I am trying to connect to a remote servre via FTP in my VB 6.0 application.
I tried connecting to remote server using Inet but it gave status unknown error (code:120089). So I am trying to do this by batch file. I created a batch file as below:-
open 192.168.1.3 22
root
!@#%RedHat%)(*
cd "/opt/test"
put "C:\envars.exe" "envars.exe"
bye
( username is ‘root’ &
password is !@#%RedHat%)(*
)
I tried running the batch file from the command prompt as follows:-
C:>ftp -s:F:\testScript.txt
Now I am getting the following error:-
“ftp: connect : unknown error number”
Previously I was getting message,
“connected”
followed by,
” connection closed by remote host.”
However, I am able to connect to this server using Filezilla.
Please let me know if you are able to figure out what is the issue.
Thanks in advance
Sujit
Are you sure you want to be connecting to port 22? 21 is the usual FTP port.
Additionally, you should try to execute that script manually (run
ftpand type them in yourself) to see where the error occurs. It may be that your firewall is blocking return traffic in active mode (see if Filezilla is running in passive mode).Based on your comment, you’re definitely connecting to a secure FTP server. The
ftp.exeprogram that comes with Windows only does standard FTP.A quick Google of
"ftps client for windows"turns up many possibilities, one of which is a secure FTP client in Putty, a tool we use (and highly recommend) at work. Another issftpthat comes with CygWin.I don’t believe either of these allow you to specify a password other than interactively. They rightly assume that you’re using them for security purposes and having a password in plaintext in a script would render the security moot.
Your best option is to set up shared keys the way SSH wants you to. That is the most secure way.
However, if you’re more interested in ease of setup rather than security, you can just use
expectto await the password prompt and then give your password to the SFTP program. CygWin also comes withexpect(Putty doesn’t) so I’d suggest using that.