copy last file


 
Thread Tools Search this Thread
# 1  
copy last file

hi,

I have a script which export a database evernight in a directory.

The script alos ftpies the files in the directory to another machine.

Problem is I am copying/ftping everything in the directory. This directory will grow overtime so I want to know I ftp last export in directory and not everything as is doen currently.


Thanks
# 2  
This makes no sense to me. You should know what file you are exporting to so you should only ftp that file. Or you should be cleaning up at the end of ftping the file so you aren't sending more files. You should not be putting this in a directory that will have other files. You should be either setting up your file name so it is special for each day (and ftping only that one) or putting it in such a place or in such a way that it overwrites yesterday export and you still only have one file to send.

Please give more info on your set up or incorporate the suggestions given. Post OS and version and DB and version.
# 3  
If it's not too, too big, why don't you post your script in here? Or at least the part of your script which copies the file to the other directory and then ftp's it to the other machine...

Like thehoghunter is suggesting, it sounds like you may have a problem with the logic in your code.
# 4  
Below is the script,

Cheers


# Set enivironment variables

ORAENV_ASK=NO
ORACLE_SID=cidw1
DATESTAMP="`date +'%d%m%y%H%M'`"
PATH=/usr/dt/bin:/usr/bin:/usr/ccs/bin:/usr/ccs/lib:/usr/ucb:/etc:/usr/sbin:/usr/local/bin:/u001/oracle/product/817/bin:.
LOGDIR=/u001/home/oracle/test/dump
LOGFILE=/u001/home/oracle/export_ftp.log
SSH=/usr/local/bin/ssh

export PATH LOGFILE DATESTAMP BASE SSH ORACLE_SID EXPORT_DIR

perform_export_wiadmin()
{
cd $LOGDIR
rm test*
exp / file=test.$DATESTAMP.dmp log=test.$DATESTAMP.log owner=wi_admin >> $LOGFILE

if [ `cat $LOGFILE | grep -i "Export terminated successfully without warnings" | wc -l` = 0 ]
then
echo "####################################"
echo "** Export of WI_ADMIN Schema successful **"
echo "Scriptname:" $0
echo "Started:"$START "Completed:" `date`
echo "####################################"
# exit 0
else
echo "####################################"
echo "** Export of WI_ADMIN unsuccessful **"
echo "Scriptname:" $0
echo "Started:" $START "Completed:" `date`
echo "####################################"
exit 1
fi
}

perform_ftp()
{
cd /u001/home/oracle/test/
ftp -inv inditf2 <<EOF
user oracle robo3cop0
bin
cd /u001/home/oracle/test/dump/
mget test*.*
bye
EOF
}

main()
{
perform_export_wiadmin
perform_ftp
}
main
#exit 0
# 5  
Hi,

I might be missing the point of the question but can't you just do

get test.$DATESTAMP.dmp

instead of

mget test*.*

Matt.
# 6  
Thanks, you got the point still learning but I'll get there.

Cheers once again
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #14
Difficulty: Easy
The F9 function key needs to be pressed during a Windows reboot to enter into Safe Mode.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to copy file 3 times and rename based on another file

In the below bash I am trying to copy the only text file (always only one) in /home/cmccabe/Desktop/list/QC/metrics.txt and rename each of the 3 text files according to /home/cmccabe/Desktop/test/list.txt using lines 3, 4 ,5. This format (that is list.txt) is always 5 lines. Thank you :). ... (12 Replies)
Discussion started by: cmccabe
12 Replies

2. Shell Programming and Scripting

Change the file name and copy old file content to new file names.

Hi, I have a files in a directory as below :- ls -1 mqdepth-S1STC02 proc-mq-S1STC01 proc-mq-S1STC02 proc-mq-S1STC03 Whereever i have S1STC i need to copy them into new file with file name S2STC. expected output :- ls -1 mqdepth-S2STC02 proc-mq-S2STC01 proc-mq-S2STC02... (3 Replies)
Discussion started by: satishmallidi
3 Replies

3. Shell Programming and Scripting

how to copy the directory but not copy certain file

Hi experts cp bin root src /mnt but not copy bin/bigfile any help? ( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum) Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies

4. UNIX for Dummies Questions & Answers

Hoe to copy selected strings from file into another text file

Hi Experts, I just want to copy some selected strings from a a file into a new .txt file . I am using below command to find the data now want to copy the search results into another .txt file please help me . find /Path -exec grep -w "filename1|filename1|filename1|" '{}' \;... (2 Replies)
Discussion started by: mumakhij
2 Replies

5. Programming

how to copy downloaded file into my source file folder (putty/unix)

I need to "Ensure that when you download libchat.a from the VLE you have copied it to the same folder on ius as your source files. You then refer to the library (and the libraries it needs) with: gcc -o outputfile sourcefile.c -L. -lchat -lsocket -lnsl" But I have no idea what this means! (I... (2 Replies)
Discussion started by: fakuse
2 Replies

6. Red Hat

Copy certain file types recursively while maintaining file structure on destination?

Hi guys, I have just been bothered by a fairly small issue for some time now. I am trying to search (using find -name) for some .jpg files recursively. This is a Redhat environment with bash. I get this job done though I need to copy ALL of them and put them in a separate folder BUT I also... (1 Reply)
Discussion started by: rockf1bull
1 Replies

7. UNIX for Dummies Questions & Answers

Copy a windows CVS file to the unix server as a svs file

I so desperately need a script to copy a windows csv file to my unix server and i know these should be at dummies but i have no bits. it is life & no job situation help please. thanks (1 Reply)
Discussion started by: zhegal
1 Replies

8. Shell Programming and Scripting

Match File and Copy File Script (Homework, Closed)

Can you please help on this? I am looking for the shell script which does following:- step 1: It should open the file /u/manish/input/FileIndex.dat and read line by line step 2: Once first line is read (for ex: File1), we have to find a file, that contains this matching... (4 Replies)
Discussion started by: teteguru1
4 Replies

9. Shell Programming and Scripting

Bash copy file contents into an existing file at a specific location

Hi all I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far: File A line 1 line 2 line 3 line 4 ... (6 Replies)
Discussion started by: gshepherd7
6 Replies

Featured Tech Videos