Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2241

Re: Command line cannot fwrite, browser can

Message-Id <8844491.SEqChMirdb@PointedEars.de>
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-06-18 08:20 +0200
Subject Re: Command line cannot fwrite, browser can
Newsgroups comp.lang.php
References <Xns9F07924644CD1arbpenyahoocom@88.198.244.100>
Followup-To comp.lang.php

Followups directed to: comp.lang.php

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-17 21:22 +0000
  Re: Command line cannot fwrite, browser can Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-06-18 00:16 +0000
  Re: Command line cannot fwrite, browser can Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 20:35 -0400
    Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-18 03:05 +0000
  Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-18 08:20 +0200
    Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-18 08:05 +0000
      Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-18 10:27 +0200
      Re: Command line cannot fwrite, browser can Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-18 08:19 -0400
        Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-18 16:08 +0000
          Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-22 11:48 +0200
            Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-23 03:44 +0000
              Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-23 09:55 +0200
                Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-23 15:29 +0000
                Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-24 01:00 +0200
  Re: Command line cannot fwrite, browser can Bernd Schulz <ask_me_for_email@invalid.invalid> - 2011-06-18 13:10 +0200

csiph-web