Operating System - HP-UX
1825630 Members
3170 Online
109683 Solutions
New Discussion

Re: FTP to another HP machine; auto logon

 
SOLVED
Go to solution
Tim Hawk
Occasional Contributor

FTP to another HP machine; auto logon

I want to setup a script that will run under cron that will ftp files from one HP machine to another. How do I specify the userid and password when the script connects?
8 REPLIES 8
Justo Exposito
Esteemed Contributor

Re: FTP to another HP machine; auto logon

Hi,

You can use the .netrc file in the home directory for the user. you must put in the file:
machine machinename login username password userpassword

And thats all.

Regards,

Justo.

Help is a Beatiful word
Krishna Prasad
Trusted Contributor

Re: FTP to another HP machine; auto logon

You can try this

echo "
open hostname
user username password
put file
close
" | ftp -i -n

Positive Results requires Positive Thinking
Christopher Caldwell
Honored Contributor
Solution

Re: FTP to another HP machine; auto logon

ftp -n -v <<-EOF
open [A.B.C.D]
user [USERNAME] [PASSWORD]
binary
put [FILENAME]
quit
EOF

Replace the bracketed expressions with stuff that's appropriate for your system. Make sure EOF appears in the leftmost column.
Tim Hawk
Occasional Contributor

Re: FTP to another HP machine; auto logon

What is the difference between machine and machinename?
Darrell Allen
Honored Contributor

Re: FTP to another HP machine; auto logon

Hi Tim,

machine, login, and password are keywords. machinename is the name of the server you want to connect to.

man netrc for more info.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Anthony khan
Frequent Advisor

Re: FTP to another HP machine; auto logon

You can do some thing like this.

ftp -inv transrva <user username passwd
bin
lcd dir
cd dir
mput *
bye
EndFTP
Darrell Allen
Honored Contributor

Re: FTP to another HP machine; auto logon

I found out something interesting a couple of weeks ago concerning automated ftp scripts called via cron. Here's what I posted in that thread:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x3e6050011d20d6118ff40090279cd0f9,00.html

<< begin quote >>
Are you running the ftp script from www's crontab? Or are you running it from root's crontab (su'ing to www)?

It will work if you use www's crontab but "su - www -c ftpscript" in root's crontab is going to fail. man netrc says:

If the .netrc file contains password or account information for use other than for anonymous ftp, its owner must match the effective user ID of the current process. Its read, write, and execute mode bits for group and other must all be zero, and it must be eadable by its owner. Otherwise, the file is ignored.

I think that may be your problem. I don't know how to correct your issue other than to allow www to run cron (/usr/lib/cron/cron.allow).

<< end quote >>

Unfortunately for Vishwa my reply didn't help. But I thought you may run into it so...

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
harry d brown jr
Honored Contributor

Re: FTP to another HP machine; auto logon

Tim,

If the two HP machines are within the same LAN/WAN and not over the internet, then you can use "rcp", which is a LOT easier to script than "ftp".

Now if you MUST proceed with "ftp", then I suggest you use "perl's" FTP modules that are easy to use:

Look at Clay's answer:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x47f235067c18d6118ff40090279cd0f9,00.html


live free or die
harry
Live Free or Die