A
A
Aidar2016-11-07 17:53:59
PHP
Aidar, 2016-11-07 17:53:59

Why is the file not being moved to the folder?

Hello! I need to download an html page and put it in a separate folder.
I found an example in the open spaces:
I create a file crontask.php

<?php
exec ('wget -O somefile.html -x http://www.example.com/somefile.html');
exec ('mv somefile.html ./myfolder/');
?>

And I run crontask.php via SSH with the full path.
/usr/local/bin/php -f /home/accountname/site.com/www/crontask.php

During the launch process, it can be seen that the file was downloaded, but the myfolder folder was not found

mv: cannot move `somefile.html' to `./myfolder/': Not a directory

The crontask.php file itself is located at the root. Why can't he see myfolder?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Saboteur, 2016-11-07
@saboteur_kiev

exec('mv somefile.html ./myfolder/');
Specify full paths to somefile.html and myfolder. The command is not executed in the default directory where you expect it to be.

M
Max, 2016-11-07
@MaxDukov

specify the full path to myfolder

A
Alexey, 2016-11-07
@alsopub

Try like this:

cd /home/accountname/site.com/www/; /usr/local/bin/php -f crontask.php

L
lubezniy, 2016-11-07
@lubezniy

Why is PHP here? You can easily replace two lines of the shell script, and there will be no dependence on php.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question