Results 1 to 9 of 9
Hi Team,
I'm new to scripts and I'm looking for a script which will automatically download my PDF's and documents from particular location, which are at a remote Server.
This ...
- 01-05-2008 #1Just Joined!
- Join Date
- Nov 2007
- Location
- I Live at chennai
- Posts
- 9
Scripts For Automatic Downloads
Hi Team,
I'm new to scripts and I'm looking for a script which will automatically download my PDF's and documents from particular location, which are at a remote Server.
This need to run at my system start up.
Any Ideas on How to start this Stuff. I hope this is a combination and set of
Wget commands in scripts put into cron or Init.d. Can any one please help me on this, Any Useful Links ??
I need some help on this,
Thanks on Advance
- 01-05-2008 #2
I'm not particularly specialized in what you want, but nobody else has answered, so I'll get the ball rolling.
Yep, the script should go in init.d somewhere. That varies from distribution to distribution, so either consult your CentOS documentation or just do this at the command line:
and see what file names come up. The files might well be sufficiently self-documenting that they provide you with all you need to know about where your scipt should be called from. Just keep in mind that things like environment variables (particularly PATH) are not defined when the system is first coming up, so you'll have to specify everything explicitly. For example, the line which calls your script is going to have to specify not just your script name, but the full path, like:Code:find /etc -name '*init*'
As another example, if you wish to use wget, you won't be able to just sayCode:/fred/barney/foo/bar/baz/script.sh
You'll have to know where it is, and specify that. For example, suppose you do this at the command line (and I recommend that you do):Code:wget
The output from that (for example, /usr/bin/wget) is how you need to specify wget in your script.Code:which wget
If all this is to happen just when your system comes up (and not, say, every hour or day), then you can skip the cron stuff.
Other than that, try googling this:
I'm sure that others here will jump in with more specific recommended links.Code:bash tutorial
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 01-05-2008 #3Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
A basic explanation that should work on most systems.
Log in as root, create a file in "/etc/init.d/" and save it as "ftp.sh":
Make the file executable:Code:#!/bin/sh ftp /i /n <<EOF open <hostname> user <username> <password> get <filename> quit EOF
In /etc/inittab you can check the default runlevel, something like: "id:2:initdefault".Code:chmod a+rx /etc/init.d/ftp.sh
In this case the default runlevel is 2, now create a symbolic link to that file in "/etc/rc2.d"
Now the script should run when you start up your machine.Code:cd /etc/rc2.d ln -s ../init.d/ftp.sh S19ftp.sh
Regards
- 01-05-2008 #4
Where to place your script
Quoth Franklin52:
Except that I note in other posts by cicero_dhoom that he's running CentOS. According to this, he wants to place a symbolic link not in directory (for example) /etc/rc2.d, but in (for example) /etc/rc.d/rc2.d.In /etc/inittab you can check the default runlevel, something like: "id:2:initdefault".
In this case the default runlevel is 2, now create a symbolic link to that file in "/etc/rc2.d"
Further, if cicero_dhoom wishes to use ftp as in Franklin52's example, he should remember to use the full pathname of ftp, obtained by doing this at the command line:
Other than that, Franklin52's advice will send cicero_dhoom well on the road to success.Code:which ftp
--
Bill
Old age and treachery will overcome youth and skill.
- 01-07-2008 #5Just Joined!
- Join Date
- Nov 2007
- Location
- I Live at chennai
- Posts
- 9
Thanks Guys,
That was very Much helpful indeed.
The tricky part is to How am I going to download the Files which are generated often.
I have a script which generates regular PDFs on Demand. I need to automatically download, only the PDfs which are the Latest ones stored with Epoh values. I'm planning to use date -d '1970-01-01 UTC <epoh value> sec ' command to convert the epoh value back. I'm using the Mysql DB to store these values on a Table.
Any Ides on these...
- 01-07-2008 #6
I'm not sure how you're going to get there from here, but if you decide to use ftp (as in Franklin52's example), maybe you can use ftp's "cd" command to get to the directory where the PDF's are stored,and then ftp's "dir" command to get the names of all the files in that directory. Then exit from ftp, slice'n'dice the output to get the names of the guys you need to download, and get into ftp again if necessary.
Does this help?--
Bill
Old age and treachery will overcome youth and skill.
- 01-15-2008 #7Just Joined!
- Join Date
- Nov 2007
- Location
- I Live at chennai
- Posts
- 9
Thanks Bill,
Most of the searches are with the same Ideas as yours.
The thread was very much helpful indeed.
Thanks again
- 01-16-2008 #8Just Joined!
- Join Date
- Jan 2008
- Posts
- 10
I'd do the following, place the latest PDFs in the www dir and echo their names in a file, and then have a while true script which fetches that file, loops thru it and wget's domain/filename while keeping track of which files I've already downloaded locally in a file used to compare the fetched data (if that makes any sense)
I can probably throw something together if you want me to.
- 01-21-2008 #9Just Joined!
- Join Date
- Nov 2007
- Location
- I Live at chennai
- Posts
- 9
Thanks for the useful tips,
I will try these out and lets see the out come.
Thanks again


Reply With Quote