Operating System - HP-UX
1753808 Members
8047 Online
108805 Solutions
New Discussion юеВ

Re: ftp inside a unix script to an nt server

 
SOLVED
Go to solution
Matt Szary
Advisor

ftp inside a unix script to an nt server

I am trying to ftp from inside of a unix script to an nt machine. I use the following syntax
ftp $sysname
user "$username" "$passwd"
put filename PATH
bye


I have tried this numerous different ways I am unable to get past the login into the nt server . When I run the ftp command from the command line everything works perfect. Does anyone know the best way to do this?
8 REPLIES 8
John Palmer
Honored Contributor

Re: ftp inside a unix script to an nt server

You need to use ftp -n from within a script to disable 'auto-login'.

See man ftp.

Regards,
John
Rick Garland
Honored Contributor

Re: ftp inside a unix script to an nt server

There are numerous posts regarding FTP and the automation of. Can do a search for FTP within the forums.

Here is short (not complete) script that should help you get started:

ftp -n -v $HOST << ENDFTP
user
getput
ENDFTP

Lots of additional options can be placed into the script. This would be a minimum to get working.
John Palmer
Honored Contributor

Re: ftp inside a unix script to an nt server

You will also have to supply the ftp commands either from a file or a 'here' document:-

ftp -n $sysname << EOD


EOD
Tom Danzig
Honored Contributor

Re: ftp inside a unix script to an nt server

You can try this inside your script:

ftp $sysname << EOD
user "$username" "$passwd"
cd PATH
put filename
quit
EOD

James R. Ferguson
Acclaimed Contributor

Re: ftp inside a unix script to an nt server

Kim:

Specify ftp -n

For a good range of examples and options in constructing ftp scipts, see:

http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0x00517e990647d4118fee0090279cd0f9,00.html

...JRF...
Tracey
Trusted Contributor
Solution

Re: ftp inside a unix script to an nt server

You can also create a .netrc file in the home direcotory of the Unix user that contains a line such as:

machine login password

words not in <> are literals, the <> fill in with you parameters. The .netrc file MUST be permits of read only for the owner chmod 400 .netrc
Alan Riggs
Honored Contributor

Re: ftp inside a unix script to an nt server

I definitely recommend using a .netrc file rather than encoding the user and password designations within the script. If anybody other than the effective user will have read access ot the script you have just compromised the userid & passwd on your NT domain.

You can still use the inline redirection (here document) to encode the file transfer commands, etc.
Tracey
Trusted Contributor

Re: ftp inside a unix script to an nt server

I forgot that this system doesn't like backslashes between "domain" and user ID there should be two (2) backslashes instead of one.