Hi everybody,
I sent this to the php.windows-group but got no answer, so I'll try again
here :-)
Since I'm not used to working under Windows-OSes (never really knew why,
now I do..) it took me a while to get moving. I put together a small
project but now I'm really stuck. Not even reading the entire internet
(well most of it anyway) did help. So maybe someone can give this a short
look:
I need to transfer a file via net to some remote server.
I need to encrypt, since I could not find a way to use something like sftp
under WinNT / php I tried pscp (PuTTY Packet). Now this works fine when
started manually, even when embedde in a php-script it works when I execute
this script directly, however it does NOT work when I call the script via
cgi-bin from Apache. I tried all those strange things with prepending
something like "command /c" etc, nothing worked. In fact the pscp
executable IS called it just vanishes in nirvana. No error, no output, no
filetransfer.
In Compact:
- WinNT & Apache 1.3.something & php4.06 as cgi-exe
- Dir-Structure:
C-somepath-Apache-htdocs-somepath-scp-scp.php
-PHP-php.exe
-Tools-PuTTY-pscp.exe
- a short php-script:
---
scp test\n";
echo "\n";
$pscp="C:/somepath/Tools/Putty/pscp";
$user="some_user";
$host="some_host";
$pass="some_pass";
$target_path="Deliver";
$target_file="targetfile";
$source_path="C:/somepath/Tools/PuTTY";
$source_file="sourcefile";
$connect_string=sprintf("%s -v -pw %s %s %s@%s:%s", $pscp, $pass,
sprintf("%s/%s", $source_path, $source_file),
$user, $host,
sprintf("%s/%s", $target_path, $target_file) );
$ret_arr=array();
echo'exec($connect_string, $ret_arr, $ret_var); '."\n";
echo"exec($connect_string, $ret_arr, $ret_var); "."\n";
$res_var=exec($connect_string, $ret_arr, $ret_var);
echo "results --\n";
echo "res_var: ".$res_var."\n";
echo "ret_var: ".$ret_var."\n";
echo "ret_arr: ".$ret_arr."\n";
foreach ($ret_arr as $value)
echo "> ".$value."\n";
echo "\n";
echo "\n";
?>
---
OK, it does not matter if I use exec, system, passthru or whatever, the
effect is the same: pscp is called, works for some seconds, the server is
not contacted (checked logs), the browser stops ("loaded") with the result:
---
exec($connect_string, $ret_arr, $ret_var);
exec(C:/somepath/Tools/Putty/pscp -v -pw some_pass \
C:/somepath/Tools/PuTTY/sourcefile \
some_user@some_host:Deliver/targetfile, Array, );
results --
res_var:
ret_var: 0
ret_arr: Array
---
So far so good (depends actually).
Now, there are two strange things:
a) when executing another command (I tried 'tar xvzf somefile.tgz', yes,
under WinNT) - no problem. takes a few seconds, returns a list of all
extracted files in $ret_arr. Same with things like "dir" etc.
b) when calling scp.php directly it does work:
C:> somepath\PHP\php C:\...\scp.php
the source is copied to target, the result shows the verbosity-messages
like 'login...authenticated...session...copying...'. Everything is fine.
Hmmm:
The tar-test shows that the arguments are ok when handed to the executable
(even checked via a batch-file echoing the args). The direct call shows
that pscp works and can be used from inside php.
So where is the difference when apache calls php via cgi?
Ok folks, I'll be glad for any hints or suggestions since being a little
under pressure to get this working and I really got no clue where else to
look :-(
Any Ideas anybody???
Anyone wants a cookie???
Thanks in advance,
Christian
--
Christian Reiner
Entwicklung & Projekt Management
ImageWare Components GmbH
Berliner Freiheit 36, D - 53111 Bonn - Germany
Tel: +49 - 228 - 969 85 - 37
Fax:+49 - 228 - 969 85 - 84
E-Mail: [EMAIL PROTECTED]
Web:www.imageware.de
ImageWare Components GmbH ist ein Beteiligungsunternehmen
der T-Venture, die Corporate Venture Capital Tochter der
Deutschen Telekom AG und der Bonn-Innova GmbH & Co.KG
Interessiert an weiteren Neuigkeiten?
Klicken Sie sich durch unsere neue Homepage unter www.imageware.de
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]