note 76276 added to function.ssh2-shell

From: Date: Mon, 09 Jul 2007 08:17:41 +0000
Subject: note 76276 added to function.ssh2-shell
Groups: php.notes 
Request: Send a blank email to php-notes+get-128314@lists.php.net to get a copy of this message
Hi, we could also use shell_exec to execute multiple related commands separated by semicolon (;). And I figured out problem that sometimes arise related to the execution of complex java c/c++ programs. All we need to do is to set the required environment variables. I have a environment variable in .bash_profile. This variable would be set when I log into my account normally through shell. But when we use ssh2_connect(), the environment variables in the .bash_profile are not set, all we need to do is export the required environment variables with shell_exec(); example: $conn = ssh2_connect($ipaddress); ssh2_auth_password($conn,$username,$passwd); $cmd1="/path/to/program1"; $cmd2="/path/to/program2"; $env1="export Variable_name1=path1"; $env2="export Variable_name2=path2" $stream = ssh2_exec($connection,"$env1; $env2; $cmd1; $cmd2");//this would execute all the //commands and return // stream stream_set_blocking($stream, true); while($o=fgets($stream)){ echo $o.'<br>'; } ... ... Thanks, Vikram Gopu . http:\\my.lsu.edu/vgopu1 ---- Server IP: 69.147.83.197 Probable Submitter: 72.207.245.109 ---- Manual Page -- http://www.php.net/manual/en/function.ssh2-shell.php Edit -- https://master.php.net/note/edit/76276 Del: integrated -- https://master.php.net/note/delete/76276/integrated Del: useless -- https://master.php.net/note/delete/76276/useless Del: bad code -- https://master.php.net/note/delete/76276/bad+code Del: spam -- https://master.php.net/note/delete/76276/spam Del: non-english -- https://master.php.net/note/delete/76276/non-english Del: in docs -- https://master.php.net/note/delete/76276/in+docs Del: other reasons-- https://master.php.net/note/delete/76276 Reject -- https://master.php.net/note/reject/76276 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128314) next »