How to connect to a remote system using ftp command? - ftp

I have to transfer files from machine to another(both windows platform) and for that purpose i am trying out with ftp commands. So, i am opening command prompt and typing the following:
C:\WINDOWS\system32> ftp
ftp> open sample.com
ftp> username
Now when i enter username it throws me error as "Not connected".I am not getting what am i doing wrong. The user name is absolutely correct.Please suggest how do i connect to remote system using ftp commands.

It seems that the "open" command failed and you are not really connected to the ftp server.
Here is what a good connection looks like:
C:\>ftp
ftp> open ftp.microsoft.com
Connected to ftp.microsoft.akadns.net.
220 Microsoft FTP Service
User (ftp.microsoft.akadns.net:(none)): anonymous
331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
230-Welcome to FTP.MICROSOFT.COM. Also visit http://www.microsoft.com/downloads.
230 User logged in.
ftp>
Here the username is "anonymous" and I provided that at the "User" prompt.
You can do this in another way:
C:\>ftp
ftp> open ftp.microsoft.com
Connected to ftp.microsoft.akadns.net.
220 Microsoft FTP Service
User (ftp.microsoft.akadns.net:(none)):
501 Invalid number of parameters.
Login failed.
ftp> user anonymous
331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
230-Welcome to FTP.MICROSOFT.COM. Also visit http://www.microsoft.com/downloads.
230 User logged in.
ftp>
Here I did not enter the username but used the "user" command provided by the ftp client to provide the username "anonymous"
None of these look like what you are experiencing. Could this be because you have removed some of the information in the interest of confidentiality? If so, that makes it difficult to help.
Also, it would help to read up on some help on using FTP command.
Here is one I found off google that I think would walk you through FTP commands: FTP and SFTP Beginners Guide with 10 Examples

Related

Windows FTP login using "user" command in script fails

I have a simple ftp script file to upload a file to a server.
Script.txt contains:
open ftp.host.com
user Fred PASSword
send c:\hotsheet.dat
disconnect
quit
The cmd line is
Ftp -s:Script.txt
It starts processing correctly but the login fails. I think it is using all lowercase for my password.
The Windows ftp has two login modes. In the default one (the one you are using), it tries to login automatically once the open command is issued and reads the credentials from the script. So the script would have to look like:
open example.com
username
password
send c:\hotsheet.dat
disconnect
quit
So what is happening with your script is that the user Fred PASSword is used as a username as a whole (and similarly the send c:\hotsheet.dat is used as a password). You can tell that, if you add -d (debug) switch:
---> USER user Fred PASSword
331 Please, specify the password.
---> PASS send c:\hotsheet.dat
530 Login incorrect.
Login failed.
Or you can prevent the automatic login with -n switch:
ftp -s:Script.txt -n
And then explicitly login using the user command, just as your script is doing.

FTP from terminal if username contains #?

How do you connect to an FTP server from the command line if your username is your email address? Usually I login in like this:
ftp username#ftp.server.com
But if my username is an email address, it doesn't work:
ftp myname#mysite.com#ftp.server.com
I've tried using an escape character \#, and putting the username in quotes. Neither work. I looked in the man pages and searched Google to no avail.
Take a look to man ftp and you shoud use $HOME/.netrc file containing the username. See:
user User [Password] [Account] Identifies the local user (User)
to the remote FTP server. If the Password or Account parameter is not specified and the remote server requires it, the ftp command prompts for the password or account locally. If the Account parameter is required, the ftp command sends it to the remote server after the remote login process completes.

My FTP batch script is stuck on "200 PORT command successful" and doesn't upload the files to server

I've tried everything I found in Google results about
200 PORT command successful
but nothing has helped.
Can anyone assist to solve this issue please?
The code of "runScript.bat:
ftp -s:"C:\automation\fileup.bat" myserver.com
The code of "fileup.bat:
username
password
ascii
cd "/public_html/reports/"
lcd "C:\automation\tests\HtmlReporter"
prompt
mput *
disconnect
close
bye
The console log:
C:\automation>ftp -s:"C:\automation\fileup.bat" myserver.com
Connected to myserver.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 7 of 500 allowed.
220-Local time is now 04:40. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
User (server26.000webhost.com:(none)):
331 User username OK. Password required
230-OK. Current restricted directory is /
230-449 files used (4%) - authorized: 10000 files
230 16742 Kbytes used (1%) - authorized: 1536000 Kb
ftp> ascii
200 TYPE is now ASCII
ftp> cd "/public_html/reports/"
250 OK. Current directory is /public_html/reports
ftp> lcd "C:\automation\tests\HtmlReporter"
Local directory now C:\automation\tests\HtmlReporter.
ftp> prompt
Interactive mode Off .
ftp> mput *
200 PORT command successful
This looks like a typical problem with the FTP active mode. The server cannot connect back to your machine to establish a data transfer connection.
That typically happens as nowadays most client machines are behind a firewall or NAT or both, what prevents the FTP active mode from working. To make the active mode working you need to open your firewall (not recommended) and/or configure NAT routing rules.
See my article on FTP modes and configuring network for the active mode.
Or you use the passive FTP mode. The Windows ftp.exe client does not support the passive mode though, what makes it pretty useless nowadays.
So you need to use another command-line FTP client. A majority of FTP clients do support the passive mode.
For example with WinSCP your runScript.bat would be like:
winscp.com /command ^
"open ftp://username:password#myserver.com/" ^
"cd /public_html/reports/" ^
"lcd C:\automation\tests\HtmlReporter" ^
"put *" ^
"exit"
Note that WinSCP defaults to the passive mode.
For details see WinSCP guides for:
Automating file transfers to FTP server
Converting Windows FTP script to WinSCP script
(I'm the author of WinSCP)
I had exactly the same problem ("200 PORT command successful" stuck on the screen forever), and I was able to solve it.
First of all, there are lot of posts on the Internet saying that Windows ftp.exe doesn't support passive mode. This is not true:
ftp> quote pasv
227 Entering Passive Mode
In my case I had a Windows 2012 R2 server with a real IP. Switching to the passive mode didn't solve the problem, I was still stuck at "200 PORT command successful". At the same time WinSCP worked fine. The solution was to create an inbound firewall rule which allowed external connections from FTP server to the local ftp.exe.

Write a Script to respond to prompts with specified text

I am writing a script which will automatically capture a screenshot and trigger iSight to take a still photo when the script is run, then upload it to FTP. Everything is perfect other then one thing, my FTP requires a username and password to be entered when prompted (after both images are captured)
heres what I have:
echo “GOLDENEYE ACTIVATED….”
screencapture -x screen.jpg
imagesnap Mugshot.jpg
ftp <YourServerHere>
Terminal Responds:
Connected to <YourServerHere>
Now, Username must be entered when this appears:
220 Welcome to <ServerDomain>, FTP server standing by ...
Name (<ServerName>.<DomainName>.:<Name>): <Type UserName Here - Hit Enter>
And, Password will be entered upon successful entry of a valid Username:
331 Hello <UserName>, your FTP account password is required:
Password: <Type Your Password Here - Hit Enter>
After the proper credentials are entered, Terminal will respond:
230-Login successful, your current directory is /
230 0 Kbytes used (0%) - authorized: 7340032 Kb
Remote system type is UNIX.
Using binary mode to transfer files.
And, to upload the images:
ftp> put /Mugshot.jpeg
ftp> put /Screen.jpeg
I am attempting to Automate the username and password entry after the prompts are given, in order for the script to be successful
the text would be, "username" and "password" to be entered after the each prompt is given.
i am completely new to terminal and scripts, just playing around in my spare time, please excuse anything which is incorrect here, thanks for ANY help and education!
A general solution is the expect command.
But for your task, it's an overkill.
The ftp reads commands from a standard input.
So just do:
ftp -n < command.txt
The -n prevents the automatic prompts for username/password. We provide these explicitly using the user command below.
The commands.txt file will look like:
open host
user user password
put /path
bye

Can we login to putty with FTP details

I tried to login with putty to the Server with FTP details Hostname, Username and Password. But it says Access Denied when i entered the Paassword.
For my another Website i entered my hostname and click open in putty, it shows "Network Error: Connection timeout".
But the 2 sites can be opened in FTP client like Smart FTP. To access through putty shall i need any permission or what else may be the problem.
Where i can find Putty Details i.e., Username and Password to login to putty in SSL. I need to execute MYsql insttruction, do File transfer etc., Please show me link to learn some commands.
If you want to use Putty to login to an FTP server you need to do it manually. You need to set a RAW connection to port 21. Once connected you need to send USER, followed by username, and PASS followed by the password.
You can find more info on RFC959 http://www.faqs.org/rfcs/rfc959.html
If you want to try another ftp software, give a shot to WinSCP.
Putty is an SSH/Telnet client not an FTP client - different protocol, different TCP port. FTP is typically exposed since it's less risk - SSH can be much more dangerous and I would suspect blocked if you're seeing a connection timeout message.
Make sure to create a folder called billing and place all the putty exe's and batch files.
echo off
echo Starting PSFTP and Logging Into FTPSITE.ORG
psftp.exe username#FTP.org -pw "PASSWORD" -b "C:\BILLING\SITE.CMD"
echo %d%%t%
move /y "C:\Interface\Charges\BILLING.EXP" "C:\Interface\Charges\Sent\BILLING%d%%t%.EXP"
echo Done Uploading Billing Results and Moving Files
exit

Resources