FTP : refused to connect problem

Hi all,
I have just started learning shell scripting. Im using Ksh.

Here is the problem.
I want to ftp all csv files in a directory from windows to a directory in unix.
the script i wrote is below:

HOST='IP address'
USER='abcd'
PASSWD='****'
ftp -n $HOST <<END_INPUT
user $USER $PASSWD
cd Z:\dir A\dir B
lcd my destination directory
binary
mget *.csv
quit
END_INPUT

the source file is in network drive Z: under directory B
when i execute this script it refuses to connect.

What is wrong with this script.

Any help appreciated. Thanks in advance

In what way does it 'refuse to connect'?

What exactly does it do?

Show what happens word for word, letter for letter, keystroke for keystroke.

@Corona688

This is the reply i get:

 
ftp: connect: Connection refused
Not connected.
Not connected.
Local directory now /my destination directory
Not connected.
Not connected.

are you sure the ftp server is running or maybe firewall disabled or accessable ??

# telnet $HOST 21
# nc -z $HOST 20-100

@ygemici

Thanks for the commands.
i tried them both and first one alone worked.
It is not getting connected actually

This is the reply i got

 
$ telnet IP address
Trying IP address...
telnet: connect to address IP address: Connection timed out
telnet: Unable to connect to remote host: Connection timed out

Does this mean that either ftp server is disabled in windows or the firewall is not allowing the connection to establish
Am i right?

I assume you tried the valid IP Address if that is correct,that is to say probably that your access is not allowed..check the the windows firewall or check the local firewall in unix

windows

NET START|find /i "Firewall"

linux

# service iptables status

unix

# iptables -L

and what is your O.S ?

@ygemici
Im using Windows XP and GNU/Linux as the unix counterpart.

I executed the linux command and seems like the local firewall is allowing ftp
the out put of the command is below:

$ ftp ipltables status
ipltables: bad port number-- status
usage: ftp host-name [port]
ftp>

ok.your syntax is not correct..
can you test like this ?

# service iptables status

or

# /etc/init.d/iptables status

@ygemici

I executed those commands and the outputs are

 
/etc/init.d/iptables status
/etc/init.d/iptables: line 46: /etc/sysconfig/iptables-config: Permission denied

$ service iptables status
-ksh: service: not found [No such file or directory]
$

what is your O.S (redhat,suse,ubuntu or other variants)

# cat /etc/*release

and

# sed -n '46p' /etc/init.d/iptables

@ygemici

im using Linux OS.. i mentioned the OS im using in comment #7

@ygemici

Im extremely sorry, i was in a hurry that day, thats why i didnt read your question properly... the OS i use is

Red Hat Enterprise Linux Server release 5.8

ok it does no matter :b: , probably in redhat, iptables is running, therefore your ftp reqests are rejected, and then you can try this

# /etc/init.d/iptables stop

after that try again..

regards
ygemici