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
ssh2_exec with a variable
Moderator: General Moderators
Hi, this is the general discussion forum
see http://www.php.net/manual/en/language.t ... ng.parsing
Your thread should be inGeneral Discussion
[...]
This forum is not for asking programming related questions.
Variable substitution doesn't take place in single quoted strings.PHP - Code
PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
see http://www.php.net/manual/en/language.t ... ng.parsing
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
sssh2_exec
volka,
Thankyou very much.
That solved my problem.
I appreciate your help.
-Nayeem
Thankyou very much.
That solved my problem.
I appreciate your help.
-Nayeem