Reputation: 10636
I need to execute commands over ssh in php. Sincere there are multiple of servers, I have to build the $file_name for each server. File name is like this: vmstat_servername. Below is the code.
$file_name="/var/vmstat_".$value;
this command is not working because the $file_name inside the single tikcs. Any ideas how I can make this work?
$line1= $ssh->exec('head -3 $file_name');
Upvotes: 0
Views: 42
Reputation: 23011
Use double quotes, so that the variable will be evaluated:
$line1= $ssh->exec("head -3 $file_name");
Upvotes: 2