PHP Classes

How to run a Bash script via PHP and match the output?

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  How to run a Bash script via PHP and...  
Subject:How to run a Bash script via PHP and...
Summary:Match the status of the ssh tunnel
Messages:2
Author:cost
Date:2016-12-31 11:26:44
Update:2016-12-31 11:28:00
 

  1. How to run a Bash script via PHP and...   Reply   Report abuse  
Picture of cost cost - 2016-12-31 11:28:00
My Bash script:

#!/usr/bin/expect

spawn ssh -L10000:localhost:80 root@192.168.1.10
expect "password:" {send "password\r"}
interact

I need to match if the tunnel SSH is up, something like this:

spawn ssh -L10000:localhost:80 root@192.168.1.10
ssh: connect to host 192.168.1.10 port 22: No route to host -> if exist "No route to host" echo -> "the host is not reachable"

elseif -> output is equal to "Last login: Sun Dec 25 14:50:49 2016 from 192.168.1.90
[root@test ~]# " echo -> "the tunnel ssh is up"


There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.