php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21425 rename() - interesting behaviour
Submitted: 2003-01-05 05:16 UTC Modified: 2003-01-05 08:26 UTC
From: linux at psoftwares dot hu Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.0 OS: Debian GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: linux at psoftwares dot hu
New email:
PHP Version: OS:

 

 [2003-01-05 05:16 UTC] linux at psoftwares dot hu
it's an interesting thing about the rename() function:

the code which doesn't work:
<?php
$base = "/home/phanatic/temp/";
$from = "users";
$to = "userdata";
rename ($base.$from, $base.$to);
?>

and which works (if the script is in the same dir):
<?php
$from = "users";
$to = "userdata";
rename ("./".$from, "./".$to);
?>

error message for the first code:
Warning: rename(/home/phanatic/temp/users,/home/phanatic/temp/userdata) [http://www.php.net/function.rename]: No such file or directory in /home/phanatic/temp/test_rename.php on line 8

my configure line:
./configure --with-layout=GNU --with-mysql=shared --with-pgsql=shared --with-gd=shared --with-gd2 --enable-ftp --with-calendar --with-posix --
enable-sockets --enable-cli --enable-cgi --enable-pcntl --with-bz2=shared --with-zlib-dir=/usr/include/ --prefix=/usr --sysconfdir=/etc/php

hope i could provide all the infos needed to fix this problem...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-05 07:13 UTC] nicos@php.net
The error is clear it can't find /home/phanatic/temp/users, probably because of permissions or probably because it's NOT the good directory. Are you sure ./ is /home/phanatic/temp/?

Anyway this is bogus, if you need any help please take a look at http://www.php.net/support.php .


Thank you for your report.
 [2003-01-05 07:21 UTC] linux at psoftwares dot hu
the file is there, i'm sure about it... and the script itself is in '/home/phanatic/temp', too!!! so it's not a bogus in my opinion... just test it yourself.
 [2003-01-05 07:24 UTC] nicos@php.net
Can you please show us the permission of the directory and of the files please? 

It looks I really CAN NOT reproduce it there...

Thank you.
 [2003-01-05 07:34 UTC] linux at psoftwares dot hu
perms of the file:
-rw-r--r--    1 phanatic phanatic       99 Jan  5 10:36 users
perms of the dir:
drwxr-xr-x    5 phanatic phanatic     4096 Jan  5 12:06 temp

but in my opinion, if this happens because of the permissions, then why does the second script work?

thanx in advance...
 [2003-01-05 07:38 UTC] derick@php.net
Assuming that you run this script with the Command Line version (not through your webserver), can you run:

strace php yourscript.php

and put this output somewhere online? We should be able to figure out what fails in the script.

Derick
 [2003-01-05 08:26 UTC] linux at psoftwares dot hu
solved the problem... there were really no problems, just didn't realize a bug in my script ;(

sorry for the inconvenience...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 15:01:36 2025 UTC