Windows 7 Batch Script - "Access Denied" error when using FTP - windows

I wrote a batch script. I am on WINDOWS 7 and try to ftp file, which are on Linux
open MYIP
MYUSER
MYPASSWORD
hash
cd /home/mktftp/upload/coverimages
asc
get DONE.SVRIMG.14102014
quit
exit /b
and get output below:
ftp> Connected to 10.160.2.52.
open 10.160.2.52
220 10.160.2.52 FTP server ready
User (10.160.2.52:(none)):
331 Password required for user
530 Access was denied.
I don't understand, why it is not working.

Related

Login Bluehost FTP using Shell Script on Amazon AWS

Facing error in script while login FTP on Bluehost server using Shell Script on Amazon AWS.
I am able to login FTP using SSH successfully but when use Shell script to automate the FTP login it shows error LOGIN FAILED.
#!/bin/sh
HOST='HOST IP'
USER='username#domainname.com'
PASSWD='password'
ftp -inv $HOST << EOT
user $USER $PASSWD
EOT
exit 0
Below is the result:
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 04:11. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Remote system type is UNIX.
Using binary mode to transfer files.
331 User username#domainname.com_ OK. Password required
530 Login authentication failed
Login failed.
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.
Use "quote USER" and "quote PASS" in your script
#!/bin/sh
HOST='HOST IP'
USER='username#domainname.com'
PASSWD='password'
ftp -inv $HOST << EOT
quote USER $LOGIN
quote PASS $PASSWORD
EOT
exit 0
i hope help you
This issue may be unique to BlueHost.
For years I had been successfully using a BASH script with a number of hosting providers for logging in and uploading changes to my SpamAssassin config file. After moving to BlueHost, the script failed, stalled at the password entry prompt, and eventually timed out with a login failure.
The script failed every time even though I was able to successfully login by manually initiating an FTP session and typing/answering the login prompts from a CLI terminal window.
I found the BlueHost password prompt did not like my script password which included a "$" dollar sign as part of the password. The "$" dollar sign embedded in the password was not being passed to the FTP password prompt even when the $PASSWORD variable was quoted as "$PASSWORD". Changing the password to replace the "$" dollar sign character with another character allowed the script to successfully login and upload.

FTPing inside of a KSH script from AIX to Windows to GET a file

#!/bin/ksh
. $HOME/bin/init.ksh
# log_start
exit_if_not_dgftp
# EXPIRE_DAYS=30
# create_arc_dir
# handle_error abort $? "Command create_arc_dir failed" $USER
# purge_archive $EXPIRE_DAYS
WORK_FILE=RetriesExceeded.csv
USER=LawsonIT-FinMM#test.org
HOST=lawsonfax.test.org
# Ftp the file
# Ftp username and password is in .netrc
$FTP -v $HOST
lcd $WORK_FILE
get RetriesExceeded.csv
quit
# archive_file $WORK_FILE
# /law/bin/mpack -s "Fax Retries Exceeded" $WORK_FILE_OUTPUT $USER
# log_stop
exit 0
[dgftp#lawapp2]/lawif/bin$ get_lawson_fax.ksh
Connected to lawsonfax
220 Microsoft FTP Service
331 Password required for dgftp.
230 User logged in.
ftp> quit
221 Goodbye.
/lawif/bin/get_lawson_fax.ksh[33]: lcd: not found
/lawif/bin/get_lawson_fax.ksh[34]: get: not found
/lawif/bin/get_lawson_fax.ksh[35]: quit: not found
[dgftp#lawapp2]/lawif/bin$
Explanation: The script connects fine to the lawson fax server, but stops at a FTP prompt. I can type in 'Get' interactively and it works, but in a KSH script it just stops at ftp prompt and then when I quit it gives three not found errors. If I am on the AIX server and manually FTP, open lawsonfax, get retriesexceed.csv there is no issue pulling the file.
Try using shell-redirection:
ftp -v "$HOST" <<DONE
lcd $WORK_FILE
get RetriesExceeded.csv
quit
DONE

How to connect to a remote system using ftp command?

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

Connect to FTP via Shell Script issue

While I am able to log in fine manually through the command line, for some reason my log in fails when I try to programmatically log in my Unix Shell script. I am using the same exact script which is successful for another FTP server and I know the values I’m passing are correct. Could this be a configuration issue on the FTP server side?
I get the error: 530 User cannot log in. Login failed.
Here is the code I'm using:
ftp -inv $FTPSERVER << EOF
user $USERNM $PASS
lcd $DLPATH
binary
prompt
mget *.txt
bye
EOF

How to convert Windows FTP script to WinSCP?

I need to use WinSCP in my legacy vb6 code. I always used my script like this:
open ftp.myserver.com
myusername
mypassword
passive on
cd myfolder\
ascii
put C:\temp\test.xml test.xml
close
quit
Similar script (with little change) always worked for sslftp, psftp, etc.
Now I need to create script to make this WinSCP work but it keeps throwing "host not found error". I'm not even trying the script. I'm trying it on the command window.
winscp> open ftp.myserver.com
Searching for host...
Network error: Connection timed out.
same ftp works on regular command line ftp:
ftp> open ftp.myserver.com
Connected to myserver.
220 Gene6 FTP Server v3.10.0
User (...): myuser
331 Password required for myuser
Password:
230 User manager logged in.
How do I run WinSCP? The documentation doesn't show any such example.
WinSCP defaults to the SFTP protocol on the port 22. If you want to use the FTP, you need to specify that explicitly.
Also username and password come in session URL as part of the open command, not on separate lines. The passive mode is specified using the -passive=on switch.
open ftp://myusername:mypassword#ftp.myserver.com -passive=on
The ascii mode is specified using the -transfer=ascii switch of the put command (though the separate ascii command is also understood for compatibility):
put -transfer=ascii C:\temp\test.xml test.xml
It's the exit, not the quit.
See the complete guide for converting Windows FTP script to WinSCP.
You should also read the guide to automating file transfers to FTP server.

Resources