Executing an "expect" script using PHP

I have an "expect" script set up to log on to a remote sftp location, upload available files from my end.

I have a php process that will create those files.  My biggest issue is how can I cannot connect these two processes?

I've tried "exec()" and it doesn't seem to respond (though it does come up asking a question that I need to answer YES OR NO to when I echo the result)...but thats unexpected so I'm not sure exactly what its doing.

Is this even possible?

Step 1: PHP creates and drops files into a home directory setup for the customer.
Step 2: Script (expect) pushes the files to the remote location.
Step 3: Script moves the local files into a outgoing_complete folder.

Step 2 is where I'm having the issue.  Any help would be grateful.  Thanks.
Who is Participating?
Dave BaldwinFixer of ProblemsCommented:
PHP normally runs under the permissions of the web server which means it does not have permission to run local programs or logon to remote systems.  There are ways around that but you have to have control of your own server to run things like 'suexec'.
Gabriel7Author Commented:
I have full control over my server.
IT Degree with Certifications Included

Aspire to become a network administrator, network security analyst, or computer and information systems manager? Make the most of your experience as an IT professional by earning your B.S. in Network Operations and Security.

PHP has the FTP functionality so why not use that which will provide you with the full control as well as error detection.

Here is an ftp connection reference

Modifying server settings to accomplish a task that can be completed through other means often means that you are compromising the security settings that could (Murphy's Law) will end up compromising your system.
Gabriel7Author Commented:
I would rather NOT modify security settings.  I did try the information you sent...but it simply times out with
Warning: ftp_login() expects parameter 1 to be resource, boolean given in...

...then fails...

This is a sftp connection I'm trying to make...I tried the ssl_connect variant...with no luck. :(
Gabriel7Author Commented:
// set up basic connection
$conn_id = ftp_ssl_connect($ftp_server, $ftp_port);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
Dave BaldwinFixer of ProblemsCommented:
For SFTP, you would want to install the ssh2_sftp extension from PECL: http://php.net/manual/en/function.ssh2-sftp.php
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.