- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting help required
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
Forums
Discussions
Discussions
Discussions
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
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
03-16-2004 06:46 AM
03-16-2004 06:46 AM
I am looking for a script , that can identify the files, created on a date say for Eg today and rcp them over. And on the next day, if there is a file with the same name it shouldn't rcp that , it should skip that file.
I got answers from some experts , which I am pasting below. But about the skipping the file ie if there is a file with same name, yesterday comparing it with today, how do we do that? I have some thing like one below in place.
***********************************************
#!/bin/sh
TODAY=`date |awk '{print $2, $3}'`
for i in `ll |grep "$TODAY"|awk '{print $9}'`
do
rcp $i otherserver:/somedir
done
***********************************************
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 06:49 AM
03-16-2004 06:49 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 06:58 AM
03-16-2004 06:58 AM
Re: Scripting help required
Is there a way of comapring the file names created today and for tomorrow , if the same file name exists then that file has to be left out or do something like a grep -v on that file and rcp the rest over. I am basically looking for some thing to compare.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 06:59 AM
03-16-2004 06:59 AM
Re: Scripting help required
You could write a script that runs at the end of the day that looks for new files and maintains its own list of these files in a text file.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 06:59 AM
03-16-2004 06:59 AM
Re: Scripting help required
http://hpux.connect.org.uk/hppd/hpux/Networking/Admin/rsync-2.5.7/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 07:01 AM
03-16-2004 07:01 AM
Re: Scripting help required
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 07:09 AM
03-16-2004 07:09 AM
Re: Scripting help required
You will need a script file and an awk file.
Put the following into the script file:
#!/bin/sh
touch .rfile.today .rfile.yesterday
rm .rfile.today
TODAY=`date |awk '{print $2, $3}'`
for i in `ll |grep "$TODAY"|awk '{print $9}'`
do
echo "TOD" $i >> .rfile.today
done
cat .rfile.yesterday .rfile.today | sort -b -k2,2 > .rfile.combined
awk '{print "YES",$2}' .rfile.today > .rfile.yesterday
awk -f .rfile.awk < .rfile.comb > .runme
chmod +x .runme
./.runme
The second file should be called .rfile.awk and should contain:
BEGIN {prev="xyzzy";}
/^YES / {prev="";dacount=0;}
/^TOD / {if (dacount>0)
{print "rcp ",prev," otherserver:/somedir "};
dacount=1; prev=$2;
}
END {if (dacount>0)
{print "rcp ",prev," otherserver:/somedir "};}
Obviously you need to replace the "otherserver/somedir", but you get the idea.
Best regards,
Kent M. Ostby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 07:24 AM
03-16-2004 07:24 AM
Re: Scripting help required
Hi,
Please have a look at rdist commnad.
From rdist man page:
rdist - remote file distribution program
DESCRIPTION
rdist facilitates the maintaining of identical copies of files over
multiple hosts. It preserves the owner, group, mode, and modification
time of files if possible and can update programs that are executing.
Regards,
MB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 08:54 AM
03-16-2004 08:54 AM
Re: Scripting help required
am I right to assume, that the files get created written to, closed and never touched again, or are they updated a second time?
If not and all you need are the files modified in the last 24h then you might want to use
find ./ -type f -mtime -1 -exec rcp "{}" otherserver:/somedir ";"
There is a slight chance to get the creation time. If noone touches the inode with chmod, chown or the like then ls -lc gives you the creation date/time.
greetings
Michael