![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
New Coder ![]() Join Date: Jun 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
Linux: SCP file to diff directory/change filename using PHP or call sh script fm PHP
Hello all,
First I'm using a Linux computer and trying to write commands into php script to copy a file from one directory to another. Been trying different things to no avail, would seem might be a simple fix...trying to just copy a file that will have a different filename every hour over to a generic filename already saved in a different directory and save over old data in the file using PHP script. Actually works when I run manually...but not when ran using crontab, not sure why other than maybe $remote_file doesn't have permissions or something and will only copy when I run it manually? Any simple fix for this? Been trying to use the system command, PHP Code:
PHP Code:
Any help appreciated! Thanks Last edited by nuebelhor; 11-05-2009 at 03:31 AM.. Reason: put tabs in for php |
|
|
|
|
|
PM User | #2 |
|
God Emperor ![]() ![]() Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 5,123
Thanks: 2
Thanked 554 Times in 542 Posts
![]() ![]() ![]() |
PHP has a rename() function. It wants full file paths from and to.
If its working from the browser, but failing from the crontab, I'd suspect filepermissions are to blame. I also assume that $remote_file is somehow declared and valid. Also, you will find that system, exec and `` are often disabled for security reasons in PHP.
__________________
Code:
struct User *upFou;
userInit(upFou, "Fou-Lu", 1);
printf("%s has %s to %s\n", (*upFou).Name, !quitSmoking(upFou) ? "FAILED" : "SUCCEEDED", (*upFou).Smoker == 1 ? "FAIL" : "PASS");
// Fou-Lu has FAILED to FAIL? Lol
|
|
|
|
|
|
PM User | #3 |
|
Senior Coder ![]() ![]() Join Date: Dec 2007
Posts: 4,658
Thanks: 374
Thanked 562 Times in 551 Posts
![]() ![]() |
put this at the begining of the file and see what's happend:
PHP Code:
I don't understand why do you need php for this job. best regards |
|
|
|
|
|
PM User | #4 | |
|
Senior Coder ![]() ![]() Join Date: Dec 2007
Posts: 4,658
Thanks: 374
Thanked 562 Times in 551 Posts
![]() ![]() |
Quote:
![]() best regards |
|
|
|
|
|
|
PM User | #5 | |
|
God Emperor ![]() ![]() Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 5,123
Thanks: 2
Thanked 554 Times in 542 Posts
![]() ![]() ![]() |
Quote:
Oh, also I assumed that the crontab is actually executing the PHP command first.
__________________
Code:
struct User *upFou;
userInit(upFou, "Fou-Lu", 1);
printf("%s has %s to %s\n", (*upFou).Name, !quitSmoking(upFou) ? "FAILED" : "SUCCEEDED", (*upFou).Smoker == 1 ? "FAIL" : "PASS");
// Fou-Lu has FAILED to FAIL? Lol
|
|
|
|
|
|
|
PM User | #6 | |
|
New Coder ![]() Join Date: Jun 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
rename() function
Quote:
|
|
|
|
|
|
|
PM User | #7 |
|
God Emperor ![]() ![]() Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 5,123
Thanks: 2
Thanked 554 Times in 542 Posts
![]() ![]() ![]() |
Methinks an ownership/permission problem. Oesxyl will probably be able to help you more on this issue; he knows linux a lot better than I. Who made the file, was it a manual creation or was it created through php via Apache?
Running it manually, I assume you mean served through apache? And for shell, are you using root or the same user executing the cron job? Also, I assume you're commanding you're cron with something like /usr/bin/php or wherever you're PHP is located?
__________________
Code:
struct User *upFou;
userInit(upFou, "Fou-Lu", 1);
printf("%s has %s to %s\n", (*upFou).Name, !quitSmoking(upFou) ? "FAILED" : "SUCCEEDED", (*upFou).Smoker == 1 ? "FAIL" : "PASS");
// Fou-Lu has FAILED to FAIL? Lol
|
|
|
|
|
|
PM User | #8 | |
|
Senior Coder ![]() ![]() Join Date: Dec 2007
Posts: 4,658
Thanks: 374
Thanked 562 Times in 551 Posts
![]() ![]() |
Quote:
This seems to be a old problem( op have another thread with some subject, similar at least). best regards |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|