Answer the question
In order to leave comments, you need to log in
How to properly execute exec in php?
How to write such code correctly so that it is executed and the value is written to the variable?
$per = exec('hddtemp /dev/sda | awk \'{print $4}\' | cut -c 1-2');
echo $per;
[[email protected] ~]# hddtemp /dev/sda | awk '{print $4}' | cut -c 1-2
45
Answer the question
In order to leave comments, you need to log in
Found the problem. Thanks for the tip Cyril Saksin The problem is that in the console I tried from the root, and the puff is executed from the user. Specified to the user the full path to hddtemp and the problem was solved.
Example:
$result = `/usr/sbin/hddtemp /dev/sdb | awk '{print $4}' | cut -c 1-2`;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question