|
Posted by Brent Baisley on 10/14/05 16:11
In your example, the problem is that the name has spaces, which the
shell uses as a delimiter. So "That Won't Move/" is kind of being
considered parameters instead of part of the dir. Using the command
line (i.e. shell/terminal) will give you more feedback as to what is
happening (/some/dir/Dir: No such Directory).
You need to either escape the characters or enclose it in quotes. For
me, I always find it easier to just enclose directory names in quotes.
$source_dir = '"/some/dir/Dir That Won't Move/"';
On Oct 12, 2005, at 10:11 PM, -k. wrote:
> I'm having trouble moving some directories. My script works fine on
> some directories but doesn't
> move others. It seems to have trouble with directories with non
> alphanumeric charters. I'm running
> Red Hat FC2. I'm trying to move the directory basically like this...
>
> <?Php
>
> $source_dir = '/some/dir/Dir That Won't Move/';
> $dest_dir = '/some/other/dir/'
>
> $cmd = escapeshellcmd("mv ".$source_dir." ".$dest_dir);
> $result = shell_exec($cmd);
>
> ?>
>
> Is there some way to escape the characters in the directories? For
> example if i put a "\" in front
> of blank spaces it takes care of those (same for "'","(" etc.) but
> that obviously doesn't take
> care of everything. I'm hoping there is something easy i'm
> overlooking here that will escape all
> the characters.
>
>
>
>
> -k.
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
Navigation:
[Reply to this message]
|