Operating System - HP-UX
1833569 Members
4509 Online
110061 Solutions
New Discussion

FTP from UNIX to MS server

 
SOLVED
Go to solution
Marty Metras
Super Advisor

FTP from UNIX to MS server

I want to FTP some datafiles from my Unix box HP-UX 10.20 to my MS server as part of my nightly jobs.
I need a script to do this. When I do this interactively it works fine.
My script gets stuck in the login.
I wount to have this script simple.
Connect, Login, send the files, and logout.
I have never done this before with FTP cant be heard.
I tryed
ftp <open [IP address]
username
password
EOF

It gets stuck on the login.
Can you help?
Marty
The only thing that always remain the same are the changes.
6 REPLIES 6
Volker Borowski
Honored Contributor

Re: FTP from UNIX to MS server

HI Marty,

you need to use .netrc for authentication or
use the user-command in your script. Goes:

ftp <open [IP address]
user username password
...do the rest ...
EOF

Hope this helps
Volker

James R. Ferguson
Acclaimed Contributor

Re: FTP from UNIX to MS server

Hi Marty:

Change 'ftp << EOF' to 'ftp -n << EOF' and try your script.

...JRF...
Marty Metras
Super Advisor

Re: FTP from UNIX to MS server

Ya, I did that.
My Script looks like this:

$ cat test_ftp.sh
ftp <verbose
open ABC
user image xyz123
EOF

This is what I get
$ ./test_ftp.sh
Verbose mode on.
Connected to ABC.
220 abc Microsoft FTP Service (Version 2.0).
Name (ABC:image): 331 Password required for user image xyz123.
Password:

I think I am missing some thing.
Marty
The only thing that always remain the same are the changes.
Volker Borowski
Honored Contributor
Solution

Re: FTP from UNIX to MS server

Marty,

James is right, you need to provide -n

-n Do not attempt "auto-login" upon initial connec-
tion. If auto-login is not disabled, ftp checks
the .netrc file in the user's home directory for
an entry describing an account on the remote

Volker
Glynn Aherne_1
Advisor

Re: FTP from UNIX to MS server


Try this

ftp -n -v -i << EOD
user
transfer files
quit
EOD
James R. Ferguson
Acclaimed Contributor

Re: FTP from UNIX to MS server

Hi again:

The following (with the -n option works):

#!/usr/bin/sh
ftp -n << EOF
verbose
open thehost
user uuu ppp
get /tmp/stuff
close
EOF

Without the -n option, as below, fails:

#!/usr/bin/sh
ftp << EOF
verbose
open thehost
user uuu ppp
get /tmp/stuff
close
EOF

This hangs looking like:

Name (thehost:uuu): 331 Password required for user uuu ppp.
Password:

Regards!

...JRF...