FTP using script not working (for transfering file from a remote unix server to windows PC.)

hi,
Im using the following code for FTP

#!/usr/bin/ksh
ftp -v -n "10.29.45.11" << cmd
user "mahesva" "mahesva123"
get rtl.tar
quit
cmd

Below is the log when i run the above code
**********************************

Connected to 10.29.45.11.
220 (vsFTPd 2.0.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
331 Please specify the password.
230 Login successful.
local: rtl.tar remote: rtl.tar
227 Entering Passive Mode (10,29,45,11,210,37)
150 Opening BINARY mode data connection for rtl.tar (45502 bytes).
WARNING! 196 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 File send OK.
45502 bytes received in 0.046 seconds (9.7e+02 Kbytes/s)
221 Goodbye.

***************************************************

but when i look in C drive of my PC ...rtl.tar is not there..why the tarnsfre is not success.
But log is showing file is sent...

You can just google or search in the forum on "Automating FTP" / "Automate FTP".

There are tonnes of discussions on this topic :slight_smile:

1 Like

hi PKK45,
i have taken this script from this forum... eventhough its showing that file is sent,im not able to find tht in my c drive of windows..
Please help me troubleshoot..

May be you have issues here:

 #!/usr/bin/ksh
ftp -v -n "10.29.45.11" << cmd
user "mahesva" "mahesva123"
get rtl.tar
quit
cmd

Rather try using this, when FTPing from UNIX to Windows

 #!/usr/bin/ksh
ftp -v -n "10.29.45.11" << cmd
quote USER $USER
quote PASS $PASS
get rtl.tar
quit
cmd

I have a script and it works fine :slight_smile:

1 Like

hi PKK,
i have used ur script as below,
mahesva and mahesva123 are username and password for this VNC server

#!/usr/bin/ksh
ftp -v -n "10.29.45.11" << cmd
USER "mahesva"
PASS "mahesva123"
get rtl.tar
quit
cmd

but im getting a error

+++++++++++++++++++++++++++++++++

Connected to 10.29.45.11.
220 (vsFTPd 2.0.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
?Invalid command
?Invalid command
local: rtl.tar remote: rtl.tar
530 Please login with USER and PASS.
Passive mode refused. Turning off passive mode.
530 Please login with USER and PASS.
ftp: bind: Address already in use
221 Goodbye.

+++++++++++++++++++++++++
please help ,as im a beginner in this.

@dll_fgpa

did you use

 USER "mahesva"
PASS "mahesva123"

or

quote USER "mahesva"
quote PASS "mahesva123"

I think the second case will work as expected!

1 Like

hi pkk,
thank u...im using the second case..
below is the log file..,im getting ...But transfer is not succes...still im not able to get the file in windows.
++++++++++++++++++++++

Connected to 10.29.45.11.
220 (vsFTPd 2.0.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
331 Please specify the password.
230 Login successful.
local: rtl.tar remote: rtl.tar
227 Entering Passive Mode (10,29,45,11,226,226)
150 Opening BINARY mode data connection for rtl.tar (45502 bytes).
WARNING! 196 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 File send OK.
45502 bytes received in 0.046 seconds (9.6e+02 Kbytes/s)
221 Goodbye.

++++++++++++++++++++++++++
please help

Are you running this from windows PC or from the unix box?

If from unix box, why are u using get? :confused:

1 Like

hi PKK,
instead of get ...what to use instead.Please help
im actually logging to a unix pc using vnc applicaton...

Scenario - Copy a file from UNIX to Windows and Script running from UNIX
command - put

Scenario - Copy file from UNIX to Windows and Script running from windows
command - get

hi pkk,
im using get as i need to get some files from unix to windows...
script is actually running on the unix machine using a vnc application which is installed in my windows OS

Since the script is running on a unix machine (considering the source file is available in it), your action should be putting that file from UNIX to Windows.

Hope this helps.

hi pkk,
i have used put instead of get ...still the file is not coming to windows..

pls see the below log

++++++++++++++++++++++++++

Connected to 10.29.45.11.
220 (vsFTPd 2.0.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
331 Please specify the password.
230 Login successful.
local: rtl.tar remote: rtl.tar
227 Entering Passive Mode (10,29,45,11,45,165)
150 Ok to send data.
226 File receive OK.
45698 bytes sent in 0.0018 seconds (2.4e+04 Kbytes/s)
221 Goodbye.
++++++++++++++++++++++++++++++++++++=

please help me troubleshoot

did you configure the local directory ?

Configure FTP Server on Windows 2003 Server - Code Samples & Tutorials

As another poster suggests, take a look at your ftp account on the Windows box and find out where that account's ftp home directory resides. That is where you will find your file if it was transferred successfully.

When mentioning Operating Systems, please be specific. "Windows" and "unix" is just too vague. Also the ftp responses you post don't look like they came from a Microsoft product.

1 Like

hi methyl,
Please give me the command for getting this...

In you ftp logs the server which is answering has 220 (vsFTPd 2.0.1) . Afaik this is a Linux product.
Are you sure that you are connecting to the right computer and not say looping back to yourself?

hi methyl,
Im using a vnc application in windows to connect to a unix server at my work place...
i need to take some file in the remote PC to my windows system using FTP function...
im running this script in the unix machine where my file reside...
please help me ...maybe i need some change in the script.

On the "unix" system, please post:

uname -a

(Blotting anything confidential like machine names with X's).

On the "Windows" PC, please post the version. e.g. Microsoft Windows XP Professsional SP3.
There are several ways of doing this, but the easiest is to start "My Computer" and look at the help/about tab.

Do you know what VNC software you are running? That might have a built-in file transfer feature.

Do you know what FTP Server software you are running on your PC?

hi methyl,

remote server OS is

 > uname -a
Linux wt-nec2 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux

windows 7 is my OS...vnc is installed in it...im getting an output report when i run some scripts and that output ...i need to FTP to my local system(windows 7)...so i added this script to my exisiting script...but not working...