LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-22-2005, 11:23 AM   #1
freddiee
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Rep: Reputation: 0
Exclamation $10 PayPal for solution - easy..


Hey hey!

I need a solution for this ASAP and will send $10 by PayPal to the first who gives me a complete solution (from paypal balance = no fee).

Anyone?

Thanks,
Freddy

----------------------------------------------------------------

I have 24 diferrent files :

xmlfile1.xml
xmlfile2.xml
xmlfile3.xml
...
...
xmlfile24.xml


Every hour, the file /home/xml/xml.xml should be replaced by one of the 24 xmlfiles, but still be named only xml.xml. Every hour, xml.xml should be replaced by the next xmlfile in line.

So this should probably be done by using a cronscript and a shell script. The server is redhat 9.0.

-------------------------------------------------------------------
 
Old 12-22-2005, 11:38 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
This'll be homework will it? And don't offer money to our members please, LQ is a community and we do this all for no fee - let's try to avoid setting a precedent.
 
Old 12-22-2005, 11:42 AM   #3
freddiee
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Original Poster
Rep: Reputation: 0
My sincere appologies,
just that I'm in need of an urgent solution..

Best
Freddy
 
Old 12-22-2005, 11:49 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,149

Rep: Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203
Grab a book on Shell programming and you will probably find this sort of thing as an example. Or look for the equivalent on-line.

I can outline the solution but I can't provide one... however, if you look around your system (say in the "/rc.d/init.d" scripts or any existing cron jobs) you might find one.

If you execute the "date" command programmatically, using the backslash {`} mechanism of the shell, you'll get a string. One particular substring is going to be the digits that you want. Extract that piece, build the file-name. Use a "cp" command to copy the file. The destination filename is always the same.

All of this is executed by "cron" once an hour.
 
Old 12-22-2005, 11:57 AM   #5
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 10, Linux Mint 11
Posts: 148

Rep: Reputation: 18
Code:
cp /home/xml/xmlfile`date|cut -d' ' -f4|cut -c1-2|sed s/^0//`.xml /home/xml/xml.xml
Put that in a script (/etc/cron.hourly/move_xml.sh), and change the pemissions ($ chmod 700 /etc/cron.hourly/move_xml.sh) and run the script once an hour ... I.E.

$ crontab -e

Add the following line

0 * * * * /etc/cron.hourly/move_xml.sh

executes on the hour every hour, every day, 24/7.

The back ticks kind of shoot the enclosed part off into its own little shell, then returns the results. The first cut statement grabs the time on the system, and the second pulls only the hour. The sed is needed because single digit hours are prefaced with a 0, but your files don't preface those numbers, so the leading 0 has to be stripped.
 
Old 12-22-2005, 11:59 AM   #6
michapma
Member
 
Registered: Oct 2003
Location: Zürich
Distribution: Debian
Posts: 537

Rep: Reputation: 39
Wow, all that for free.
 
Old 12-22-2005, 02:46 PM   #7
freddiee
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Original Poster
Rep: Reputation: 0
THANKS A LOT!!

Please let me know your paypal e-mail..

Best
Freddy

Quote:
Originally Posted by Hobbletoe
Code:
cp /home/xml/xmlfile`date|cut -d' ' -f4|cut -c1-2|sed s/^0//`.xml /home/xml/xml.xml
Put that in a script (/etc/cron.hourly/move_xml.sh), and change the pemissions ($ chmod 700 /etc/cron.hourly/move_xml.sh) and run the script once an hour ... I.E.

$ crontab -e

Add the following line

0 * * * * /etc/cron.hourly/move_xml.sh

executes on the hour every hour, every day, 24/7.

The back ticks kind of shoot the enclosed part off into its own little shell, then returns the results. The first cut statement grabs the time on the system, and the second pulls only the hour. The sed is needed because single digit hours are prefaced with a 0, but your files don't preface those numbers, so the leading 0 has to be stripped.
 
Old 12-22-2005, 02:50 PM   #8
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Quote:
Originally Posted by freddiee
THANKS A LOT!!

Please let me know your paypal e-mail..

Best
Freddy
When I said not to do this, I wasn't joking. DO NOT OFFER LQ's MEMBERS MONEY FOR SOLUTIONS.

Do not send your email address. If you want to send receive money, do it away from LQ.
 
Old 12-22-2005, 02:53 PM   #9
freddiee
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Yiikes..sorry

Many many thanks to you hobbletoe!

Best
Freddy
 
Old 12-22-2005, 10:32 PM   #10
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 10, Linux Mint 11
Posts: 148

Rep: Reputation: 18
The thanks are all that I need. I helped because I enjoy figuring out things like this, and I really like to help out where I can. That is also why I explained what everything was doing so that Freddiee and others that stop by the thread can learn and understand it.

I don't have a PayPal account. Money was never the goal, only to help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB-stick easy solution (KDE 3.4+) powadha Debian 0 09-18-2005 05:23 AM
Dual Boot Solution --- Really Easy!!! altair401 LinuxQuestions.org Member Success Stories 10 07-09-2004 03:04 PM
Dual Boot Solution --- Really Easy!!! altair401 Linux - General 2 07-06-2004 04:54 AM
alternative easy filtering solution goldeneyexs Linux - Software 0 06-17-2004 08:00 AM
A hell of a time = an easy solution buyo LinuxQuestions.org Member Success Stories 1 09-15-2003 01:10 PM


All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration