Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp synchronized mget/mdel

Status
Not open for further replies.

razalas

Programmer
Apr 23, 2002
237
0
0
US
Need to do an mget for an unspecified number of files and follow that with an mdel that only deletes the specific files that were "gotten". Is there a way to do this all within ftp?

Seems like I will have to do the mget first, then outside of ftp, identify the files that were retrieved and turn around and issue a 2nd ftp to delete only the files that were retrieved.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Maybe try this (typed, not tested):

Code:
#!/bin/ksh

FTPSERVER="<ftpserver>"
USER="<username>"
PASSWORD="<password>"
REMOTEDIR="<remotedir>"
LOCALDIR="<localdir>"

cd ${LOCALDIR}

exec 4>&1
ftp -vn >&4 2>&4 |&

print -p open ${FTPSERVER}
print -p user ${USER} ${PASSWORD}
print -p cd ${REMOTEDIR}
print -p mget *.*

for FILE in $(ls)
do
    print -p del ${FILE}
done

print -p bye
exit

Regards,
Chuck
 
Chuck,

Interesting solution.

We generally only run bash, but if it solves the problem, its worth a try.

Thanks. I'll let you know if it works for me.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top