ssh2_exec with a variable
Posted: Fri Jun 29, 2007 7:27 pm
Hi,
I am trying to run a command on a remote machine using ssh2_exec. I can successfully get the result back. However, there is a catch:
I want to send the command with a variable name that I read from the users input.
for e.g ., if I type
$directory = '/usr/local';
ssh2_exec($connection, 'ls -ld /usr/local'); it works,
ssh2_exec($connection, 'ls -ld $directory'); does not work.
How can I make the second command to work. Is there a way or did I hit a dead end?
If there is any alternative, please let me know.
I appreciate it.
Thanks
-Nayeem
I am trying to run a command on a remote machine using ssh2_exec. I can successfully get the result back. However, there is a catch:
I want to send the command with a variable name that I read from the users input.
for e.g ., if I type
$directory = '/usr/local';
ssh2_exec($connection, 'ls -ld /usr/local'); it works,
ssh2_exec($connection, 'ls -ld $directory'); does not work.
How can I make the second command to work. Is there a way or did I hit a dead end?
If there is any alternative, please let me know.
I appreciate it.
Thanks
-Nayeem