Patrioticcow
Patrioticcow

Reputation: 27038

how to run a bash script from php?

i am trying to sun a bash script when i update something:

public function reloadServer()
{
    exec ('/var/www/html/script', $y);
    Zend_Debug::dump($y);
}

this is the script file

#!/bin/bash
# test
ssh [email protected] "server -rx reload"
echo "success"

what happens is that get the success message, but the command doesn't get run. if i run the command manually it works just fine

note: i can't use ssh2_exec because of some problems on my server

any ideas on what is happening or how can i debug that bash script ?

Upvotes: 0

Views: 299

Answers (1)

konsolebox
konsolebox

Reputation: 75458

Place your command inside a subshell and tee its output:

#!/bin/bash
# test
( ssh [email protected] "server -rx reload" ) 2>&1 | tee -a /some/where.log
echo "success"

Through that you'll see all the messages including possible messages from bash.

Upvotes: 1

Related Questions