Expect - get, then move files within FTP site?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect - get, then move files within FTP site?
# 1  
Old 03-10-2010
Expect - get, then move files within FTP site?

Trying to do the following, and it looks like Expect is probably my best bet. Any help greatly appreciated

1) Log onto ftp site
2) Go to folder
3) GET all files matching basename*.txt
4) MOVE those files to a subfolder on the ftp site. I don't need to move it on MY computer, I want to move the files on the site to a subfolder, so that if there are any problems the files are still accessable. This is acceptable by the site owner.

Example:
spawn ftp myftp
expect "username:"
send "hi\r"
expect "password:"
send "mom\r"
expect "ftp>"
send "prompt\r"
expect "ftp>"
send "cd getme\r"
expect "ftp>"
send "mget basename*.txt\r"
expect "ftp>"
(code I need - move all files I just got to folder getme\processed)
send "bye\r"
expect eof
# 2  
Old 03-10-2010
Not sure about this, but try "rename" on the ftp prompt:

Code:
rename myfile ./subfolder/myfile

assuming the subfolder exists and you have permissions to it.
Try absolute path if relative balks.

Another way would be to mput them back from your machine to the subfolder on the remote machine, although I suspect you're trying to avoid that.

tyler_durden
# 3  
Old 03-10-2010
Yes, but still need to evaluate

Yes, something like that would work... but I still need a way for expect to figure out the list of files, then loop through each and get/rename.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To merge files on FTP site before getting them

I have a job that connects to FTP site, rename, get, delete a file and then process it. The renaming is done in consideration of this is one file name into which data is being accumulated many times within 24 hour cycle. This is what happens now: ftp -i $FTPHOST <<-EOF ren... (3 Replies)
Discussion started by: migurus
3 Replies

2. SCO

FTP problem with site exec command

Hello dear Users, I am for the first time in this forum. I come from Germany. Please excuse my bad englisch. My OS is SCO open Server Release 5. I have a problem whith FTP and the command "site exec" if I use the command "ftp> site chmod 777 /tmp/startkpf.sc 200 CHMOD command successful. ... (8 Replies)
Discussion started by: fla5do
8 Replies

3. HP-UX

Scripts to move files via FTP with error checking

Hi Members, Can members please advise or suggest how to write UNIX script which move all zip files in source directory and when done delete zip files from source directory? We want to delete only on successful transfer to the destination. secondly want to add some error checking if the FTP... (1 Reply)
Discussion started by: dxj0815
1 Replies

4. UNIX for Dummies Questions & Answers

SCP -r from Secure FTP site

Hi all, My problem is simple. I would like to download the contents of a directory on an ftp site. I can access the site through windows, but there are many files and it would be too tedious to click and download each file. Thus, I am trying to use scp -r... (5 Replies)
Discussion started by: cpabrego
5 Replies

5. Shell Programming and Scripting

Problem in Downloading one day old files from FTP site

HI, I'm downloading one day old files from ftp site. Below is my script ---------------------------- printf "open $HOST \n" > ftp.cmd printf "user $USER $PASSWD\n" >> ftp.cmd printf "bin\n" >> ftp.cmd #printf "cd /Models/\n" >> ftp.cmd printf "prompt\n" >> ftp.cmd printf "for oldfile... (4 Replies)
Discussion started by: shekhar_v4
4 Replies

6. Shell Programming and Scripting

script for download files from ftp site

I'm new to scripting. I'm trying to write a script to download files from ftp site, the following is the script and the message i get after running the script. no files were downloaded :( Thanks advance! script: #!/usr/bin/ksh DAY=`date --date="-1 days" +%y%m%d` ftp -v -n "ftp.address" <<... (5 Replies)
Discussion started by: tiff-matt
5 Replies

7. Shell Programming and Scripting

Pulling a list of files from FTP site in a shell script

Hi, I am writting a shell script which will pull a list files (mentioned in one file 1.txt) from external FTP site (for ex: ftp://abcd.efghijk.com/). The 1.txt is in my local unix directory. I have username and password to connect the external FTP site. Also before I pull the files, I need... (0 Replies)
Discussion started by: spatra
0 Replies

8. Solaris

SITE command of FTP not working

Using FTP on Solaris 5.8, I am not able to use the SITE command. It says Invalid command. I am trying to change the permission of the transmitted files to -rw-rw-rw on the destination machine. Any help would be greatly appreciated. (2 Replies)
Discussion started by: gauravsachan
2 Replies

9. UNIX for Advanced & Expert Users

Polling an FTP site for a file

Hi, I'm after a bit of advice for the best way to collect files from an ftp server via a unix process. The main issue here is the frequency, the job needs to check for files every minute or so between 8am and 8pm and pull them down to the box if there is anything there. Originally the... (6 Replies)
Discussion started by: Peejay
6 Replies

10. UNIX for Dummies Questions & Answers

Site command used in ftp script

Hi everyone, can someone please tell me what can be wrong here? Script: ftp -v -n $FTPSERVER<< EOP >$LOGFILE 2>&1 user $USERID $PASSWD ascii site lrecl=500 site cyl site PRI=600 site SEC=300 lcd $FTPLOCALDIR cd $FTPTARGETDIR put $SOURCEFILE $TARGETFILE quit EOP Output:... (11 Replies)
Discussion started by: swoldering
11 Replies
Login or Register to Ask a Question