![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Delete words in File 1 from File 2 | Enobarbus37 | Shell Programming and Scripting | 14 | 02-15-2008 05:09 AM |
| Post Shell programming: Question about source a file and read data from the file | ccwq | Shell Programming and Scripting | 3 | 08-04-2007 07:28 PM |
| how to delete record in file data with index in another file? | zhynxn | Shell Programming and Scripting | 0 | 07-05-2006 09:03 PM |
| i want to delete a file based on existing file in a directory | srivsn | Shell Programming and Scripting | 3 | 04-11-2006 01:38 AM |
| To delete a file at some other unix server | dharmesht | High Level Programming | 1 | 03-23-2004 04:52 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there Everyone,
I need some help/information/advise for the following questions: I'm writing the following script: #Beginning of the script ftp -n <source server> > ${log_dir}/test_get.log << END user <user_name>@<IP Address> <passwd> verbose bin !echo "'List Files Before Getting A0 Data'" ls !echo "'Getting A0 Data'" lcd /usr/mir7/dmail/data # Destination mget A0* bye END ftp -n <source server> > ${log_dir}/test_get.log << END user <user_name>@<IP Address> <passwd> !echo "'List All A0 Data" dir A0* bye END echo "List A0 Files in Destination" >> ${log_dir}/test_get.log ls ltr A0* | grep "A0*" >> ${log_dir}/test_get.log #The End After getting the file from the source server I would like to delete the file from the source server but only the files which I have ftp to my server. Is there anyway to do it? I understand ftp do not understand "if...then...else" or "while" statements. How can I go about doing it? Any ideas/ advise/ help will be much appreciated. Thanks. wee |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
This is what you want.
Code:
#!/usr/bin/ksh
ftp -ivn <<EOJ >> /tmp/some_log_file
open server_name
user username password
asc
dir A0* /tmp/A0.lst
quit
EOJ
## at this point, we have the list of A0* files with us
echo "open server_name" >> /tmp/batch.out
echo "user user_name pass_word" >> /tmp/batch.out
awk '{print $NF}' /tmp/A0.lst | while read file; do
echo "get $file" >> /tmp/batch.out #we construct a ftp batchfile that will
echo "del $file" >> /tmp/batch.out #delete a file after it transfers it to
done #our end
echo "bye" >> /tmp/batch.out
rm /tmp/A0.lst
ftp -ivn < /tmp/batch.out >> /tmp/some_log_file
|
|
#3
|
|||
|
|||
|
hi blowtorch,
let me use your script and try it out. i will reply u once it has been tested. thanks man. wee |
|
#4
|
|||
|
|||
|
hi blowtorch,
it works!! thanks so much for the help. wee |
|||
| Google The UNIX and Linux Forums |