ftp with a script
Dear friend ,
I am going to create a customized ftp script . Scenario is stated below : Suppose, I have two big size folder "test1" and "test2" . My mission is , Firstly i make those files as a "tar" file and then transfer the files to another machine using "ftp" protocol with time stamp facility (system date with time) .Script is : ========================== Date1=`date +%d%b%Y` Date=`date +%d%b%Y`.`date +%I`.`date +%M%p` cd /test tar -cvf test1_$Date.tar test1 tar -cvf test2_$Date.tar test2 ftp -i -v -n 192.168.10.1 <<END_FTP user oracle oracle binary cd /tmp mput test1_$Date.tar mput test2_$Date.tar bye ============================== It works fine . this script create the file Like " test1_01Jan2008.08.10AM.tar " and "test2_01Jan2008.08.10AM.tar" Now my problem is : suppose file1 and file2 take 2 minutes to make "tar" file like following way : "test1_01Jan2008.08.10AM.tar" "test2_01Jan2008.08.10AM.tar" In this situation , After two minutes my system date goes to 08:12AM . So that my next two lines "mput test2_$Date.tar" and "mput test2_$Date.tar" are not executed . Because at that moment system date is 08:12AM , which are not matched with previous two lines . Here in this stage i need urs help . Can any body plz give me any suggestions ........Waiting for kind reply ... Another Question , Is it possible to ftp more than one file together ? Like following : "test1_01Jan2008.* " or "test1_01Jan2008.tar* " |
thats a hard one i think this belongs in the more advanced forums
|
I created the following script
Code:
#!/bin/bash Code:
[mymachine:~/lq/shipon_97]:./blah |
try
Code:
Date1=`date +%d%b%Y` |
Cast your dated filename to a variable and then use the variable for the the filename.
Something like this: Code:
Date=`date +%d%b%Y`.`date +%I`.`date +%M%p` |
customized ftp command
Thx kzutter ,
Ur advice is very useful . I have another issue . At the last stage of script , i add another two lines for removing the "tar" files from my local machine , Like follwoing : Date1=`date +%d%b%Y` Date2=`date +%d%b%Y`.`date +%I`.`date +%M%p` cd /test tar -cvf test1_$Date2.tar test1 tar -cvf test2_$Date2.tar test2 ftp -i -v -n 192.168.10.1 <<END_FTP user oracle oracle binary cd /tmp mput test1_$Date2.tar mput test2_$Date2.tar bye rm -rf test1_$Date2.tar rm -rf test2_$Date2.tar But this script executes at the stage of "bye" , Next two lines are not executing . Now my question is , after "ftp" command, how can i execute another lines ? |
You might want to close the here file "END_FTP". Maybe something like this,
Date1=`date +%d%b%Y` Date2=`date +%d%b%Y`.`date +%I`.`date +%M%p` cd /test tar -cvf test1_$Date2.tar test1 tar -cvf test2_$Date2.tar test2 ftp -i -v -n 192.168.10.1 <<END_FTP user oracle oracle binary cd /tmp mput test1_$Date2.tar mput test2_$Date2.tar bye END_FTP rm -rf test1_$Date2.tar rm -rf test2_$Date2.tar |
All times are GMT -5. The time now is 08:18 PM. |