I am sure there is an easy answer , but i searched and could not find.
I am basically trying to pass a variable to exec grep into a file
so
exec("snmpget -v 2c -c public $host $oid_model | cut -d':' -f4 | sed -e 's/^[ ]*//'", $model);
exec("grep $model /home/user/test.txt | cut -d':' -f1 | sed -e 's/^[ ]*//'", $new_model);
when printing my $model i get the output, when trying $new_model it does not.
Try to quote the matching pattern in grep command:
exec("grep '".$model[0]."' /home/user/test.txt | cut -d':' -f1 | sed -e 's/^[ ]*//'", $new_model);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With