1832417 Members
3327 Online
110042 Solutions
New Discussion

FTP

 
SOLVED
Go to solution
TheJuiceman
Super Advisor

FTP

Hi all,

I want to copy a file from a HP-UX server to a Netware server inside a script. I thought maybe I could do this with "ftp", but am uncertain how to string the command together. Any suggestions? Thanks.

Bob
9 REPLIES 9
bhoopathi_1
Frequent Advisor

Re: FTP

#!/bin/sh

ftp -n ipaddress << !
user
....
bye
!

TheJuiceman
Super Advisor

Re: FTP

Thanks,

However, I cannot get it to pass the user information. Any thoughts?
Steven E. Protter
Exalted Contributor
Solution

Re: FTP

Please post the script text you used.

You can't just cut and paste his script as posted.

Here is a working example.

As bad a security as this is, set two variables before executing this code:


USERNAME=userid
PASSWORD=actualpassword

export USERNAME
export PASSWORD


ftp -nv ${SERVER} << FTPEOF > /tmp/temp_log.$$
user ${USERNAME} ${PASSWORD}
#Get file
get $1
quit
FTPEOF


If this script does not work, make sure the ftpd server is working on the Netware Server.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
bhoopathi_1
Frequent Advisor

Re: FTP

If you want to handle the password securely, then you can encrypt the password.

$ echo |crypt pass >/home/crypted

then you can call this in the script

#!/bin/sh
USERNAME=username
PASSWORD=`crypt pass
export USERNAME PASSWORD

ftp -n ipaddress << !
user $USERNAME $PASSWORD
commands.......
bye
!
Nguyen Anh Tien
Honored Contributor

Re: FTP

this is my script.
USERNAME=someone
PASSWORD=passwd
WORKSTATION=IP OR HOST

ftp -nv ${WORKSTATION} << FTPEOF > /tmp/temp_log
user ${USERNAME} ${PASSWORD}
#Get file
get $1
quit
FTPEOF

let try .
tienna
HP is simple
Nguyen Anh Tien
Honored Contributor

Re: FTP

this is my script.
USERNAME=someone
PASSWORD=passwd
WORKSTATION=IP OR HOST

ftp -nv ${WORKSTATION} << FTPEOF > /tmp/temp_log
user ${USERNAME} ${PASSWORD}
#Get file
put file
quit
FTPEOF

let try .
tienna
HP is simple
Jan Sladky
Trusted Contributor

Re: FTP

Hi Bobby,

creat file with ftp command a files you want to create and launch ftp with i n v options :


/usr/bin/ftp -i -n -v < /home/sladky/CRON_MSD/ftp_sundance1.txt

cat ftp_sundance1.txt

open 10.32.113.177
user user1 passwd
bin
hash
prompt off
cd IN2
dir
mput -.txt
bye


rgds Jan
GSM, Intelligent Networks, UNIX
Scott Frye_1
Super Advisor

Re: FTP

I just got this from the forum a couple days ago. It works great as a script. I run it in a cron.

#/!/sbin/sh
#change these parameter for your environment
host_ip=172.21.xx.xxx
user_name=xxxxxx
pass_word=xxxxxx
dir=/home/sysadmin/crhcmax2
ldir=/home/sysadmin
Date=`date +%m%d`
LOG_NM=/home/sysadmin/ftpcrhcmax1.log
file_name=crhcmax2${Date}.html
mail_file=*.mail.crhcmax2

ftp -nv $host_ip << FTPEOF > $LOG_NM
user $user_name $pass_word
cd $dir
lcd $ldir
put $file_name
mput $mail_file
quit
FTPEOF
TheJuiceman
Super Advisor

Re: FTP

Thank you all for the responses. They were a big help. I especially like the encryption...nice touch!!!