That doesn't help too much. I don't think above will be a valid user on either system, on top of, on *nix systems, the back slashes if not quoted work a escape chars yielding USER=prtg_svradministrator .
Please approach the problem stepwise:
The first thing to do is to transfer a file using ftp manually from the command line. If that doesn't work then you've got no chance trying to script it.
the windows server is configured as ftp server
if I run from command prompt ftp -inv <ip address> it does connect, but does not login:
ftp -inv 10.100.48.116
Connected to 10.100.48.116.
220-FileZilla Server version 0.9.44 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit http://sourceforge.net/projects/filezilla/
Remote system type is UNIX.
ftp>
"Remote system is type UNIX" tells me you're doing this from the Windows box. Yes, by default a Windows box usually has a ftp client installed but to accept inbound ftp connections the Windows box needs to be a ftp server.
I think we all assume that, since you are posting on a Unix forum here, you are trying to connect from a Unix box to a windows box. Yes??
Right, so before you try and script anything, login as whatever user, and check the infrastructure is in place to support the ftp by invoking ftp from your command line and sending a file over to windows.
First of all don't put your password in a script! Use the $HOME/.netrc file, which has the format:
machine <dns or ip address> login <username> password <password>
one machine per line. Now you can get rid of the password in the script. You are also able to change permissions on this file so that only you can read it. As been said earlier, test with manual FTP connections and modify the script accordingly. With my suggestion of using the .netrc file the invocation of ftp will be as follows:
ftp -inv 10.100.48.116
Connected to 10.100.48.116.
220-FileZilla Server version 0.9.44 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit http://sourceforge.net/projects/filezilla/
Remote system type is UNIX.
ftp> put ftpfiles.sh
530 Please log in with USER and PASS first.
530 Please log in with USER and PASS first.
ftp> by
221 Goodbye
or :
ftp -inv 10.100.48.116
Connected to 10.100.48.116.
220-FileZilla Server version 0.9.44 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit http://sourceforge.net/projects/filezilla/
Remote system type is UNIX.
ftp> user
(username) administrator
331 Password required for administrator
Password:
530 Login or password incorrect!
Login failed.
ftp>
but the credentials are correct, please beleive me
If you're doing this on the Unix box and it's connecting to a Windows box why does it say "Remote system is type UNIX"?
I'd expect to see "Remote system is Windows".
I've just downloaded the latest filezilla server onto my Windows box and yes it says Remote system type is UNIX. Looking at the filezilla console you get the message 215 UNIX emulated by FileZilla . Mystery solved?
Stupid question directed at original poster: Did you set up any users within the filezilla server? Using your windows accounts will not work. You have to add username/password/home directory to filezilla.
ftp 192.168.1.19
Connected to 192.168.1.19.
220 Microsoft FTP Service
Name (192.168.1.19:root): emm
331 Password required for emm.
Password:
230 User emm logged in.
Remote system type is Windows_NT.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
CHARGINGSYSTEM
GGSN
SGSN
SMSC
SMSGw
exodus.241115
software
226 Transfer complete.
66 bytes received in 0.00017 seconds (382.51 Kbytes/s)
ftp> put collect.sh
200 PORT command successful.
150 Opening ASCII mode data connection for collect.sh.
226 Transfer complete.
local: collect.sh remote: collect.sh
1288 bytes sent in 0.009 seconds (140.27 Kbytes/s)
ftp> by
221
As apmcd47 has already said, don't try to put userid/passwd credentials in the script. Put a .netrc file in the home directory under which the script is running. As already said, make sure you get the access rights set read-only for the owner.
Once you've done that typing ftp <hostname> from the command line should just connect instantly.
my home directory of my unix server does not have that file! Should I create?
echo $HOME
/moneta_home
bash-3.00$ ls -al
total 6
drwxr-xr-x 2 root root 512 May 27 2011 .
drwxr-xr-x 80 root root 2048 Aug 15 10:12 ..
You have new mail in /var/mail/moneta
bash-3.00$
Set the file so you own it, and with your main group
Set the mask to 600
Make sure the ftp target name also appears in /etc/hosts with its correct ip address.
Then, when you run "ftp <nodename>" it will look up the name in /etc/hosts to get the ip address, then look for .netrc and if the target node is listed it will use the userid and password from there to connect via ftp. It should just connect instantly without asking for credentials.
echo $HOME/.netrc
//.netrc
You have new mail in /var/mail/root
root@moneta # ls -al .netrc
.netrc: No such file or directory
root@moneta #
them vi:
machine 192.168.1.19 login emm password emm
them:
chmod 0600 ~/.netrc
them tested:
ftp 192.168.1.19
Connected to 192.168.1.19.
220 Microsoft FTP Service
331 Password required for emm.
230 User emm logged in.
Remote system type is Windows_NT.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
CHARGINGSYSTEM
GGSN
SGSN
SMSC
SMSGw
collect.sh
exodus.241115
software
226 Transfer complete.
78 bytes received in 0.00048 seconds (159.66 Kbytes/s)
ftp> put vmstat.dat
200 PORT command successful.
150 Opening ASCII mode data connection for vmstat.dat.
226 Transfer complete.
local: vmstat.dat remote: vmstat.dat
8111 bytes sent in 0.016 seconds (507.89 Kbytes/s)
ftp> by
221