Problems with chdir()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicholas Geraldi

    Problems with chdir()

    I have a script that uses the chdir() function. I know the script works (
    works perfectly on my host ), but when I put the script on my server here at
    work I get the following error.

    Warning: chdir(): No such file or directory (errno 2)

    The same script works at my personal host, thats the part that bothers me.
    The host here at work is running PHP 4.3.8. Any suggestions about how to get
    this to work? or maybe another function that does the same thing as chdir().

    Nick






    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
  • eXeonical

    #2
    Re: Problems with chdir()

    Nicholas Geraldi wrote:
    [color=blue]
    > I have a script that uses the chdir() function. I know the script works (
    > works perfectly on my host ), but when I put the script on my server here at
    > work I get the following error.
    >
    > Warning: chdir(): No such file or directory (errno 2)
    >
    > The same script works at my personal host, thats the part that bothers me.
    > The host here at work is running PHP 4.3.8. Any suggestions about how to get
    > this to work? or maybe another function that does the same thing as chdir().[/color]

    Maybe the directory youre trying to chdir() exists on your personal
    computer, but does not exists on your server. Thats basically what that
    error message says, anyways.

    Comment

    • Nicholas Geraldi

      #3
      Re: Problems with chdir()


      "eXeonical" <spam.avk@mbnet .fi> wrote in message
      news:cdrjir$4ec $1@plaza.suomi. net...[color=blue]
      > Nicholas Geraldi wrote:
      >[color=green]
      > > I have a script that uses the chdir() function. I know the script works[/color][/color]
      ([color=blue][color=green]
      > > works perfectly on my host ), but when I put the script on my server[/color][/color]
      here at[color=blue][color=green]
      > > work I get the following error.
      > >
      > > Warning: chdir(): No such file or directory (errno 2)
      > >
      > > The same script works at my personal host, thats the part that bothers[/color][/color]
      me.[color=blue][color=green]
      > > The host here at work is running PHP 4.3.8. Any suggestions about how to[/color][/color]
      get[color=blue][color=green]
      > > this to work? or maybe another function that does the same thing as[/color][/color]
      chdir().[color=blue]
      >
      > Maybe the directory youre trying to chdir() exists on your personal
      > computer, but does not exists on your server. Thats basically what that
      > error message says, anyways.[/color]

      Im using readdir() to get a list of directories(and is_dir() to test to be
      sure) to change to, it should be able to work in any file system that
      supports chdir(). Both Home and work are using Linux ( Red Hat at home and
      Fidora(sp?) at Work ). But for some reason its not working at Work.




      -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
      http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
      -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

      Comment

      • Andy Hassall

        #4
        Re: Problems with chdir()

        On Fri, 23 Jul 2004 14:13:41 -0400, "Nicholas Geraldi"
        <nickgeraldi@ta conic.net> wrote:
        [color=blue]
        >
        >"eXeonical" <spam.avk@mbnet .fi> wrote in message
        >news:cdrjir$4e c$1@plaza.suomi .net...[color=green]
        >> Nicholas Geraldi wrote:
        >>[color=darkred]
        >> > I have a script that uses the chdir() function. I know the script works[/color][/color]
        >([color=green][color=darkred]
        >> > works perfectly on my host ), but when I put the script on my server[/color][/color]
        >here at[color=green][color=darkred]
        >> > work I get the following error.
        >> >
        >> > Warning: chdir(): No such file or directory (errno 2)
        >> >
        >> > The same script works at my personal host, thats the part that bothers[/color][/color]
        >me.[color=green][color=darkred]
        >> > The host here at work is running PHP 4.3.8. Any suggestions about how to[/color][/color]
        >get[color=green][color=darkred]
        >> > this to work? or maybe another function that does the same thing as[/color][/color]
        >chdir().[color=green]
        >>
        >> Maybe the directory youre trying to chdir() exists on your personal
        >> computer, but does not exists on your server. Thats basically what that
        >> error message says, anyways.[/color]
        >
        >Im using readdir() to get a list of directories(and is_dir() to test to be
        >sure) to change to, it should be able to work in any file system that
        >supports chdir(). Both Home and work are using Linux ( Red Hat at home and
        >Fidora(sp?) at Work ). But for some reason its not working at Work.[/color]

        Post some code; a minimal example that demonstrates the problem, preferably
        with a couple of examples from 'ls -l' to show what it's supposed to be
        reading.

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

        Comment

        • Nicholas Geraldi

          #5
          Re: Problems with chdir()


          "Andy Hassall" <andy@andyh.co. uk> wrote in message
          news:9tl2g01psv vfp3en8cec6qe0u 6ckbqc2oc@4ax.c om...[color=blue]
          > On Fri, 23 Jul 2004 14:13:41 -0400, "Nicholas Geraldi"
          > <nickgeraldi@ta conic.net> wrote:
          >[color=green]
          > >
          > >"eXeonical" <spam.avk@mbnet .fi> wrote in message
          > >news:cdrjir$4e c$1@plaza.suomi .net...[color=darkred]
          > >> Nicholas Geraldi wrote:
          > >>
          > >> > I have a script that uses the chdir() function. I know the script[/color][/color][/color]
          works[color=blue][color=green]
          > >([color=darkred]
          > >> > works perfectly on my host ), but when I put the script on my server[/color]
          > >here at[color=darkred]
          > >> > work I get the following error.
          > >> >
          > >> > Warning: chdir(): No such file or directory (errno 2)
          > >> >
          > >> > The same script works at my personal host, thats the part that[/color][/color][/color]
          bothers[color=blue][color=green]
          > >me.[color=darkred]
          > >> > The host here at work is running PHP 4.3.8. Any suggestions about how[/color][/color][/color]
          to[color=blue][color=green]
          > >get[color=darkred]
          > >> > this to work? or maybe another function that does the same thing as[/color]
          > >chdir().[color=darkred]
          > >>
          > >> Maybe the directory youre trying to chdir() exists on your personal
          > >> computer, but does not exists on your server. Thats basically what that
          > >> error message says, anyways.[/color]
          > >
          > >Im using readdir() to get a list of directories(and is_dir() to test to[/color][/color]
          be[color=blue][color=green]
          > >sure) to change to, it should be able to work in any file system that
          > >supports chdir(). Both Home and work are using Linux ( Red Hat at home[/color][/color]
          and[color=blue][color=green]
          > >Fidora(sp?) at Work ). But for some reason its not working at Work.[/color]
          >
          > Post some code; a minimal example that demonstrates the problem,[/color]
          preferably[color=blue]
          > with a couple of examples from 'ls -l' to show what it's supposed to be
          > reading.
          >
          > --
          > Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
          > http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space[/color]


          The code i am using is this...

          <?PHP

          function get_protect_dir (){
          return array("pictures ");
          }

          function get_dir($dir){
          $testing = chdir($dir);
          $protected_dir = get_protect_dir ();
          $directory = '';
          $j = 0;

          $dh = opendir('.');
          while ($filename = readdir($dh)){
          $dontcount = 0;
          if((!is_file($f ilename)) && ($filename != '.') && ($filename != '..') &&
          (is_dir($filena me))){
          foreach($protec ted_dir as $temp_dir){
          if($filename == $temp_dir){
          $dontcount = 1;
          }
          }
          if($dontcount != 1){
          $directory[$j] = $filename;
          $j++;
          }
          }
          }
          closedir($dh);
          return $directory;
          }

          function rec_dir($dir){
          $dir_array = get_dir($dir);
          $recurve_dir = '';

          echo "<CENTER><T ABLE SPAN=\"90%\" CELLSPACING=1 CELLPADDING=10> ";
          $counter = 1;
          foreach($dir_ar ray as $temp_dir){
          if(($counter%2) != 0){
          echo "<TR>";
          }
          echo "<TD><TABLE CELLSPACING=0 CELLPADDING=0>< TR>";
          echo "<TD><FONT SIZE=4><U>$temp _dir</U></FONT></TD></TR>";

          $recurve_dir = get_dir($temp_d ir);
          echo "<TR><TD><F ONT SIZE=2>";
          if($recurve_dir != 0){
          foreach($recurv e_dir as $temp2_dir){
          echo "<U>$temp2_ dir</U>,";
          }
          }
          echo "</FONT></TD></TR>";
          echo "</TABLE></TD>";
          if(($counter%2) == 0){
          echo "</TR>";
          }
          $counter++;

          }

          echo "</TR></TD></TABLE></CENTER>";
          }

          echo "<HTML>";
          echo "<BODY>";


          rec_dir('.');

          echo "</BODY>";
          echo "</HTML>";


          ?>

          the directory structure is very simple.

          /test
          /test/dir_function.ph p [name of that file]
          /test/test2
          /test/test2/test21
          /test/test2/test22

          At home it gives me test just like its supposed too. at work it reads the
          top level (test2 in this case) but then gives errors when it tries to
          chdir() into test2 to get test21 and test22.

          ( you should be able to copy and paste that code exactly )

          Thanks for the help,
          Nick




          -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
          http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
          -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

          Comment

          • Nicholas Geraldi

            #6
            Re: Problems with chdir()


            "Nicholas Geraldi" <nickgeraldi@ta conic.net> wrote in message
            news:4101393e_3 @corp.newsgroup s.com...[color=blue]
            > I have a script that uses the chdir() function. I know the script works (
            > works perfectly on my host ), but when I put the script on my server here[/color]
            at[color=blue]
            > work I get the following error.
            >
            > Warning: chdir(): No such file or directory (errno 2)
            >
            > The same script works at my personal host, thats the part that bothers me.
            > The host here at work is running PHP 4.3.8. Any suggestions about how to[/color]
            get[color=blue]
            > this to work? or maybe another function that does the same thing as[/color]
            chdir().[color=blue]
            >
            > Nick
            >
            >
            >
            >
            >
            >
            > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
            > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
            > -----== Over 100,000 Newsgroups - 19 Different Servers! =-----[/color]

            I got the problem fixed. Thanks for the help =)




            -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
            http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
            -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

            Comment

            Working...