tags:

views:

12

answers:

1

Hi everyone,

I have a question that has been bugging me

recently i wanted to write a webpage that will use the php-expect to SCP an image from another server and then display it in an image TAG

here is my code

<?php
// Copies file from remote host:
ini_set ("expect.timeout", 30);

$stream = fopen ("expect://scp user@server:/export/lynx/waves.png waves.png", "r");


$cases = array (
        array (0 => "*Password: ", 1 => "PASSWORD"),
        array (0 => "*yes/no)? ", 1 => "YESNO")
);

while (true)
{
        switch (expect_expectl ($stream, $cases))
        {
                case "PASSWORD":
                fwrite ($stream, "password\n");
                break;
                case "YESNO":
                fwrite ($stream, "yes\n");
                break;
                case EXP_TIMEOUT:
                case EXP_EOF:
                break 2;

                default:
                        die ("Error has occurred!\n");
        }
}

echo "<img src=\"waves.png\"/>";

fclose ($stream);
?>

This works fine when i run it from the CLi using "php sctipt.php" and i see the image being transferred and the html being printed on console. However when i call the script from my webpage it does not load the image.. I tried the complete directory path as well and still it does not work.

A: 

Problem was my httpd user did not have write permissions to the folder i was secure copying the file to

Sufi Hani