- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: mini-document management script. IF statement ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 01:42 PM
тАО12-04-2008 01:42 PM
I have a source and a destination.
If the file exists on source and destination with the same name, check to see if the source is newer. if the source file is newer overwrite the destination..
I think the statement would look like this:
if [ "$source" -nt "$destination" ]
then
cp $source $destination
else
echo Destination $destination is a newer file
fi
I define a bunch of variables that set precedent for values in the $source and $destination..
These are CIFS mounted file systems. Scripting solution on Un*x that mounts the file systems in questions and copies from Location A to Location B.
I think I may have my nesting wrong in my scripting
any ideas, suggestions or methods would be appreciated greatly..
Solved! Go to Solution.
- Tags:
- Test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 02:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 02:31 PM
тАО12-04-2008 02:31 PM
Re: mini-document management script. IF statement question
cd source_dir
for $source in `ls`
do
if $source does not exist in dest_dir
then copy it
else
if [ "$source" -nt "$destination" ]
cp $source $destination
else
echo Destination is newer
fi
fi
done
this could probably be done with "elif" too?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 02:32 PM
тАО12-04-2008 02:32 PM
Re: mini-document management script. IF statement question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 02:34 PM
тАО12-04-2008 02:34 PM
Re: mini-document management script. IF statement question
I've not use the -nt argument before, we have a web server that allows for job applicants to attach documents, the script takes files from a web server folder and moves them to a CIFS mounted file system for viewing from a 4GL application. often times the copy will bomb out.. or miss a file..
There is a process where we also copy files back to the webserver, the HR clerk will load files into a staging area, and I will list the files and copy them. Last night she loaded 27 files and 6 were missed. For the I create directories if non exist, before the move. What was supposed to have been a temporary work around is now a production must have and it isn't meeting my reliability wishes.
Below is one of the problem scripts. I am wandering it the reliability issues is related to a CIFS issue. Right now all files are moved. I'd like to do only those of "today's date"
That is would reduce network over head and perhaps eliminate timeing issues.
#!/bin/bash
#/bin/umount /mps-docs
#/bin/mount /mps-docs
echo Check mount
export p1=/upload_resumes/
export p2=/upload_resumes/backup/
export wst=/wst-docs/applicant/
export mps=/mps-docs/mps-docs/applicant/
export esu=/esu-docs/applicant/
export plv=/plv-docs/
#export ral=/ral-docs/applicant/
date > /tmp/movetime.log
echo "MOVE LOG " > movelog.log
echo NEW
for fn in `ls /upload_resumes/`
do
for dist in `echo $fn |awk '{print substr($1,1,3)}'`
# DISTRICT SPECIFIC INFORMATION
do
export dist
case $dist in
wst)
export distpath="$wst"
;;
mps)
export distpath="$mps"
;;
esu)
export distpath="$esu"
;;
plv)
export distpath="$plv"
;;
#ral)
#export distpath="$ral"
#;;
*)
;;
esac
#APPID SPECIFIC INFORMATION
for appid in `echo $fn |awk -F_ '{print $2}'`
do
echo FILENAME: $fn
export source="$p1$fn"
echo $source
export destination="$distpath$appid/$fn"
echo DONE
if [ -f "$destination" ]
then
echo "$destination" Exists
#rsync -uv $source $destination
else
if [ -d "$distpath$appid" ]
then
#cp -f $source $destination
rsync -uv $source $destination
#
# File Checking logging #
ls -la $source > /tmp/movesource.log
ls -la $destination > /tmp/movedestination.log
echo "Source Files" >> /tmp/movelog.log
cat /tmp/movesource.log >> /tmp/movelog.log
echo "Destination Files" >> /tmp/movelog.log
cat /tmp/movedestination.log >> /tmp/movelog.log
#
#
#################################################
else
mkdir $distpath$appid
mkdir $distpath$appid/Transcripts
fi
fi
#export backup="$p2`date +%Y%m%d`$fn"
ls $distpath > /tmp/"$dist"path
#cp -f $source $destination
#END OF APPID SPECIFIC INFORMATION
done
#END OF DISTRICT SPECIFIC FILE MANIPULATION
done
# END PROGRAM
done
rm -f /tmp/*path
cd /root
date >> /tmp/movetime.log
echo "File Completion Summary " >> /tmp/movelog.log
cat /tmp/movetime.log >> /tmp/movelog.log
echo "File Contents Summary" >> /tmp/movelog.log
echo ############################################# >> /tmp/movelog.log
mail -s "Move Log `date` " address@domainname.TLD < /tmp/movelog.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2008 07:54 AM
тАО12-16-2008 07:54 AM