Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 2nd Dec 2010, 01:44 PM   #1
Warrior Member
War Room Member
 
Join Date: 2010
Posts: 22
Thanks: 0
Thanked 2 Times in 2 Posts
Default
Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Hello,

I have to upload two files everyday for a promotion I'm doing. I have to do it at the same time everyday and it's quite annoying and not at the best time for me.

Anyway, I was wondering if there was a way to create a cron job so I would put my updated files in a folder and thanks to this cron job they would be transfered in the other directory to replace the "old" files?

Thanks to enlighten me.

WSO: big Forex ebook with PLR + sales letter $10 only!!

Free report: the 7 benefits of seasonal marketing
http://bit.ly/e0K2TC
david_g is offline  
Unread 2nd Dec 2010, 08:03 PM   #2
VIP Warrior
War Room Member
 
Tim Franklin's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,548
Thanks: 264
Thanked 507 Times in 300 Posts
Blog Entries: 83
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Cron is not the best method, since it is not the most secure way to do this, I would use SFTP, this can be done using a scripting command, or you could purchase a software product,

free, but complex,

Senior Advisor - http://www.unix.com

There are several software clients, they all seem to run around 85 bucks, not sure why, if you had a MAC you could just script it,

Google, AbleFtp

also you can try automate FTP or better sFTP

Bitcoin | Crypto | AI software tools and development|
Tim Franklin is offline  
Unread 2nd Dec 2010, 09:56 PM   #3
HyperActive Warrior
 
Join Date: 2010
Posts: 192
Thanks: 34
Thanked 27 Times in 23 Posts
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Google

have fun
CrhisD is offline  
Unread 3rd Dec 2010, 05:24 AM   #4
New Warrior Member
 
electrobooks's Avatar
 
Join Date: 2006
Location: Crawley South Coast, United Kingdom.
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Hi David,

Cron itself wont do the transfer but the script that the Cron job runs can. Do you have any programing experience (PHP etc) ?

If so using the php file commands should work to copy the file content from one file and create a new one with it. fopen() fgets() fputs(). See php.net for more.

Cheers

Chris

electrobooks is offline  
Unread 3rd Dec 2010, 08:44 AM   #5
perl scraper
War Room Member
 
kkoechel's Avatar
 
Join Date: 2010
Posts: 85
Thanks: 14
Thanked 8 Times in 8 Posts
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Originally Posted by david_g View Post

Hello,

I have to upload two files everyday for a promotion I'm doing. I have to do it at the same time everyday and it's quite annoying and not at the best time for me.

Anyway, I was wondering if there was a way to create a cron job so I would put my updated files in a folder and thanks to this cron job they would be transfered in the other directory to replace the "old" files?

Thanks to enlighten me.
do you have access to scp and ssh for these servers?

Here is the perl code that will do it:

HTML Code:
#!/usr/bin/perl
#scp.pl
#kkoechel.net

use strict;
use Net::SCP::Expect;

my @files = qw(	index.cgi
		work.jpg 
		whatever.file
		);
my &remotelocation = '/path/to/some/directory';
my &user = 'YOURUSERNAME';
my &password = 'YOURPASSWORD';
my &host = 'YOURHOST.senecamedia.com';
my &timeout = 75;
my &scpe = Net::SCP::Expect->new(timeout=>&timeout);
&scpe->login(&user, &password);
foreach my &file(@files){
	print "sending &file to &host:~/&owner/&filen";
	&scpe->scp(&file,"&host:&remotelocation") if &file;
}
you can run this script like this: perl scp.pl after you make the needed changes.

Using cron or windows task scheduler is easy to google, and you should to make sure you have the right syntax

EDIT: it keeps wiping out my variables, I am guessing some sort of javascript cleaner?

EDIT: OK, I replaced all the dollar signs with ampersands, you need to find and replace those back in before this will work.
kkoechel is offline  
Unread 3rd Dec 2010, 01:34 PM   #6
Warrior Member
War Room Member
 
Join Date: 2010
Posts: 22
Thanks: 0
Thanked 2 Times in 2 Posts
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Thanks to all of you for your advices and lines of code.

I was expecting to be able to do that with a simple Cron job, bad luck for me.

I don't want to spend any money for that as I just need to do this operation for 3 weeks.

I also don't have any scp access, I'm just using a simple shared hosting account.

Ok, I think I will continue to do it by hand.

Thank you again.

WSO: big Forex ebook with PLR + sales letter $10 only!!

Free report: the 7 benefits of seasonal marketing
http://bit.ly/e0K2TC
david_g is offline  
Unread 3rd Dec 2010, 06:43 PM   #7
perl scraper
War Room Member
 
kkoechel's Avatar
 
Join Date: 2010
Posts: 85
Thanks: 14
Thanked 8 Times in 8 Posts
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

What kind of access do you have? I could rewrite that for just about any logon mechanism
kkoechel is offline  
Unread 4th Dec 2010, 04:06 AM   #8
Warrior Member
War Room Member
 
Join Date: 2010
Posts: 22
Thanks: 0
Thanked 2 Times in 2 Posts
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Originally Posted by kkoechel View Post

What kind of access do you have? I could rewrite that for just about any logon mechanism
I have an access with cPanel but this is not my own server so I don't have a root access or whatever. My rights are limited as I'm using a shared hosting account.

WSO: big Forex ebook with PLR + sales letter $10 only!!

Free report: the 7 benefits of seasonal marketing
http://bit.ly/e0K2TC
david_g is offline  
Unread 4th Dec 2010, 08:01 AM   #9
perl scraper
War Room Member
 
kkoechel's Avatar
 
Join Date: 2010
Posts: 85
Thanks: 14
Thanked 8 Times in 8 Posts
Default
Re: Replace a file with a Cron job?
Share on: 
fb share twitter share gplus share more share

Originally Posted by david_g View Post

I have an access with cPanel but this is not my own server so I don't have a root access or whatever. My rights are limited as I'm using a shared hosting account.
yeah, bummer my friend. by hand it is.
kkoechel is offline  
Closed Thread


Bookmarks

Tags
cron, file, job, replace


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 10:59 AM.