FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Command line cannot fwrite, browser can
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Command line cannot fwrite, browser can [message #174570 is a reply to message #174561] Sat, 18 June 2011 06:20 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Adrienne Boswell wrote:

> Okay, I give up! I pulled the very last hair out of my head, and now I
> am asking for help.

Your posting style just begs for <http://www.catb.org/~esr/faqs/smart-
questions.html> as the only answer (in particular
<http://www.catb.org/~esr/faqs/smart-questions.html#beprecise>).

But I think I have actually found some relevant facts between the lines of
the 179-lines diary entry that you have posted in place of your good
question.

Anyhow, please read that tutorial to make it better next time.

> […]
> This is the error I am getting:
> C:\Inetpub\vhosts\aloyaltycard.com\httpdocs\groupmail>cd c:\parallels
> \plesk\additional\pleskphp5
> C:\Parallels\Plesk\Additional\PleskPHP5>php.exe c:\inetpub\vhosts
> \aloyaltycard.com\httpdocs\groupmail\groupmail.php
>
> Warning: file_get_contents(groupmail1_noname.txt): failed to open stream:
> No such file or directory in C:\Inetpub\vhosts\aloyaltycard.com\httpdocs
> \groupmail\groupmail.php on line 88
> cannot write to groupmail.html
>
> […]
> Directory of C:\Inetpub\vhosts\aloyaltycard.com\httpdocs\groupmail
> […]
> 06/17/2011 12:37 PM 3,102 groupmail.html
> 06/17/2011 01:13 PM 5,515 groupmail.php
> [...]
> 06/10/2011 05:51 PM 443 groupmail1_noname.txt
> […]
>
> Just for shits and giggles, here's the contents of my batch file as well:
> @echo on
> cd c:\parallels\plesk\additional\pleskphp5
> php.exe c:\inetpub\vhosts\aloyaltycard.com\httpdocs\groupmail
> \groupmail.php
>
> Here is the relavent PHP:

No, about 99% of it is quite irrelevant to your question. Does "reduce test
case" ring a bell?

> $filename = "groupmail.html";
> […]
> $groupmhtml1noname = "groupmail1_noname.txt";
>
> //this above file is the one it cannot find

(You don't say …)

> […]
> $groupmail = fopen( $filename,'w' ) or die( 'cannot open
> groupmail.html' );

<http://www.phpfreaks.com/blog/or-die-must-die>

> […]
> $firstpart = file_get_contents($groupmhtml1);
> $firstnoname = file_get_contents( $groupmhtml1noname );
>
> //warning comes right here

(You don't say …)

> fwrite( $groupmail,$firstpart ) or die( 'cannot write to
> groupmail.html' );
>
> //failure occurs right here

(You don't say …)

So let me get this straight:

1. You are explicitly cd-ing to c:\parallels\plesk\additional\pleskphp5
(for whatever reason)

2. You run php.exe
c:\inetpub\vhosts\aloyaltycard.com\httpdocs\groupmail\groupmail.php

3. You *wonder* why php.exe cannot find the files in the *current*
*working* *directory* (c:\parallels\plesk\additional\pleskphp5)
or can write to it?

$ cat ~/tmp/files.php
<?php echo realpath('.') . "\n";

$ php ~/tmp/files.php
/

(This is on GNU/Linux but that does not make a difference, of course.)

ISTM you should have more cups of tea[tm] before coding. Besides, you
cannot just take any PHP Web script and run it with the PHP CLI; to begin
with, the Web script runs under $_SERVER['DOCUMENT_ROOT'] in a much more
restricted environment; the CLI runs under the root of the local filesystem
(or "drive", in Windoze).


HTH

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: pagination driving me insane
Next Topic: insert query error
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 05:33:07 GMT 2024

Total time taken to generate the page: 0.04649 seconds