running php script manually and getting back to the command line?

Posted by Simpson88Keys on Stack Overflow See other posts from Stack Overflow or by Simpson88Keys
Published on 2010-06-09T13:41:03Z Indexed on 2010/06/09 13:42 UTC
Read the original article Hit count: 189

Filed under:
|
|

I'm running a php script via command line, and it works just fine, except that when it's finished, it doesn't go back to the command line? Just sits there, so I never when it's done...

This is the script:

             $conn_id = ftp_connect(REMOTE)
             or die("Couldn't connect to ".REMOTE);

            $login_result = ftp_login($conn_id, 'OMITTED','OMITTED');
            if ((!$conn_id) || (!$login_result))
               die("FTP Connection Failed");
               $dir = 'download';
               if ($dir != ".") {

                    if (ftp_chdir($conn_id, $dir) == false) {
                       echo ("Change Dir Failed: $dir<BR>\r\n");
                       return;
                    }
                    if (!(is_dir($dir)))
                       mkdir($dir);
                       chdir ($dir);
                    }

                    $contents = ftp_nlist($conn_id, ".");
                    foreach ($contents as $file) {
                            if ($file == '.' || $file == '..')
                            continue;

                            if (@ftp_chdir($conn_id, $file)) {
                               ftp_chdir ($conn_id, "..");
                               ftp_sync ($file);
                            }
                    else
                            ftp_get($conn_id, $file, $file, FTP_BINARY);
                    }

                    ftp_chdir ($conn_id, "..");
                    chdir ("..");
                    ftp_close($conn_id);

© Stack Overflow or respective owner

Related posts about php

Related posts about command-line