1753529 Members
4972 Online
108795 Solutions
New Discussion юеВ

ftp script not working

 
rookie250
Occasional Contributor

ftp script not working

hi

I have made d below ftp script but the last part of script ie. moving the files after transfer (to a location in the source server only) is not working for me.

Can anybody pls..help.in same..!!!


#######################################################
#!/bin/sh
ftp -n 10.209.13.11 <quote USER xyz
quote PASS xyz
bin
prompt
cd /test
put reports.zip reports.tmp
rename reports.tmp reports.zip
#quit
bye
#END_SCRIPT
#exit 0
echo Arun
mv -f /export/VSNL_RECS_logs/MUM_ILD/strsp/reports.zip /test_script/test/

exit 0
END_SCRIPT
#############################################################

6 REPLIES 6
Yogeeraj_1
Honored Contributor

Re: ftp script not working

hi,

does the command work when executed outside the script?

could be a permission problem.

please check

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
spex
Honored Contributor

Re: ftp script not working

Hi,

For starters, your here-document needs to end where "#END_SCRIPT" appears. In other words, uncomment that line, and remove or comment "END_SCRIPT" appearing at the end of the script.

Next make sure that the ftp user has read permission on reports.zip and write permission on /test_script/test/. Also make sure that reports.zip exists at the time the script is run. Just to be safe, substitute the absolute path to mv (/usr/bin/mv).

Try running the "mv -f ..." command separately. Do you receive any error messages?

PCS
Arturo Galbiati
Esteemed Contributor

Re: ftp script not working

Hi,
if I well understood, try this:
#######################################################
#!/bin/sh
ftp -n 10.209.13.11 <quote USER xyz
quote PASS xyz
bin
prompt
cd /test
put reports.zip reports.tmp
rename reports.tmp reports.zip
#quit
bye
END_SCRIPT
#exit 0
echo Arun
mv -f /export/VSNL_RECS_logs/MUM_ILD/strsp/reports.zip /test_script/test/

exit 0
#END_SCRIPT
#############################################################

the END_SCRIPT label has to close teh input for ftp. In this way the mv command will be executed by shell instead of ftp.

HTH,
Art
Steven Schweda
Honored Contributor

Re: ftp script not working

> quote USER xyz
> quote PASS xyz

Why not use a simple "user" command? For
example:

user user_name password

Using "quote USER" and "quote PASS" seems
like the hard way to do the job.

Also, "prompt" affects prompting for
multiple-file commands (like "mget" and
"mput"). You don't seem to be using any of
those.
Carlos M.J.
Frequent Advisor

Re: ftp script not working


Could you use something like this?
It works for me on HPUX 11i:

ftp -in < commands.txt

---File "commands.txt"---
open [machine_ip]
user [ftp_user] [ftp_password]
lcd [full_path_local_dir]
cd [full_path_dest_dir]
bin
mput [files_to_move]
bye
-------------------------

Hope this helps
lawrenzo
Trusted Contributor

Re: ftp script not working

you need to specify the full path to rename the file ie

#!/bin/sh
ftp -n 10.209.13.11 <quote USER xyz
quote PASS xyz
bin
prompt
cd /test
put reports.zip reports.tmp

rename /{fullpath}/reports.zip /{fullpath}/reports.zip

bye
!END_SCRIPT


echo Arun
mv -f /export/VSNL_RECS_logs/MUM_ILD/strsp/reports.zip /test_script/test/

exit 0

This works for me.


hello