[Klug-general] PSCP from Windows to Linux via PHP

Karl Buckland buckland.karl at googlemail.com
Thu May 5 16:35:14 UTC 2011


Hi Nathan,

I believe that, in Windows, exec("your_program.exe") actually calls:
cmd /c your_program.exe

Additionally, depending on the version of PHP you're using, PHP may,
or may not, automatically add quotes. If you're using PHP 5.2 or
earlier, then you need to surround your command with double quotes
yourself, so something like:
exec("\"your_program.exe\"");
Which would give you:
cmd /c "your_program.exe"

On linux, it all works directly and without any issues.

Hopefully that helps.

Karl


On 5 May 2011 16:59, Nathan Friend <nathan.friend at gmail.com> wrote:
> Afternoon KLUG,
> I'm using a PHP script to copy a file from a Windows machine to a Linux machine.
>
> I found PSCP, a windows version of SCP
> (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
> which works perfectly from the Windows CLI.
>
> Unfortunately when I run it from a PHP script it just hangs at the
> PSCP commend.  No errors in the Apache log, so I guess it's waiting
> for something.
>
> <?php
> exec('c:\apps\pscp -q -i c:\key\akeyfile.ppk c:\source_file.txt
> user at linuxbox:/destination/');
> ?>
>
> I'm using key files to prevent a password prompt and the -q switch to
> suppress output.
>
> Any ideas?
>
> Cheers,
>
> Nathan.
>
> _______________________________________________
> Kent mailing list
> Kent at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/kent
>



More information about the Kent mailing list