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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.