472,993 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

sftp via proc_open(): where is my prompt ?

Helloooo everyone,
I have a problem with a small solution I made some three or four years ago.
Worked flawless until deployed onto newer machines now and guess what, I
cannot fix it. Maybe some guru here can give this a look and tell a stupid
newbie like me what I miss...

The strategy is to have some kind of a shell-like wrapper and work
interactively with it from my php scripts. So I setup a wrapper object and
can write a command and readout the result until I destruct the object (and
the sftp session). Charming details about that solution:
- works with password authentication OR key based, keys with or without
passphrases.
- I use select(), so no polling or looping
- I can add commands without changing the basic strategy (class)
All in all I am happy and dont really want to reimplement things with the
ssh2-extension since I would have to adapt 20% of my application then...

I start a cli sftp process via proc_open and communicate with 5 sockets with
it. stdin, stdout, stderr, stdin-for-helper & stdout-from-helper. Don't ask
me, it works, took two weeks of my life some three years ago :-)
The stuff usuylla runs under GNU/linux, apache2 and php4 OR php5 as module
OR fastcgi. No difference in result as far as this problem is concerned.

Central turnplace is the methods Connect() & _read_output().
You see the select() call, I read from stdout (clients stdout) until I find
the prompt ("sftp >") in the output.
Now to my problem...
when using the solution on newer systems (GNU/Linux with openSSH
server/client version >= 4.2) *something* has changed. Authentication still
works (according to the server log) but I run into a socket timeout on
stdout when talking with the sftp client. That means I wait for a prompt
("sftp >") that never comes. When writing a single linebreak to stdin first
thing (after authentication) things work, apart from some secondary
stumblers...). So I wonder why the f**k do I have a write e newline first ?
When doing the same session setup from within a bash (manual) as same user,
using the same account, same client and server machine (same einsteinian
universe and so on) everything works fine. I cannot see much difference.
Obviously the client processes environment is different, but there is
nothing relevant as far as I can tell. I cannot find any matching change in
the underlying software packages like php or openssh. I can reproduce this
change in behaviour on multiple older versus newer systems, it is
reproduceable.
This is where you can take a look at the class definition.
http://mybib.imageware.de/~reiner/sftp.inc.pdf
Do not kill me because of the proprietary license, that is historical in my
company, I can release as open source if someone needs it. Or just use it,
whatever.
Oh, right, here is the ssh-askpass-helper, has to be callable by the forked
sftp client process...
http://mybib.imageware.de/~reiner/mybib_ssh_askpass.pdf
Hm, feel free to ask, I really need help with this one.
And sorry for the messy description, I really do have headaches after 3 days
of debugging...

Any help on my problem is really welcome,
arkascha
Aug 18 '08 #1
0 1828

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
4
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the...
3
by: Gus M. Creces | last post by:
Hi... I'm looking for some information, technical, white paper - whatever - on how SFTP works. I need to add SFTP capabilities into an app's present FTP capabilities. I'm not really looking for a...
0
by: Bernhard Günther | last post by:
Hello friends of php, PhP-Version is 4 on a FreeBSD-System using apache. Got a problem using ssh2.sftp. Installed correctly (libssh2, ssh2.so-module). Connecting with publickey works,...
7
by: RadhakrishnanR | last post by:
How i can implement SFTP in VB. Scenario is I want to take file from SFTP server, then after some process with the file , file will be moved to database.. Our requirement is very clear that how...
12
by: jcor | last post by:
Hi, I'm using Ubuntu 7.04. I'm writing a sript that sends files via ftp for several destinations. So far I used Net::FTP and it worked fine. My problem is that I need to send files via SFTP...
5
by: sakismat | last post by:
please help how can I get stderr from processes ($proc) in my screen without waiting the other processes to end #!/usr/bin/php <?php $con = mysql_connect("localhost", "user"); if (!$con)
4
by: sa6113 | last post by:
I want to use sftp from paramiko to copy a file from a windows machine to a Linux in the network, I use this code : host = "LinuxComputerName" (or its Ip) port = 22 transport =...
2
by: sivashanmugam | last post by:
Hi Friends, I tried to send some zips from local to remote location but the transfer is not sucess i can transfer the zips partially can some one assist me how to make it as sucess i had...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.