Hi im not good in php much i want to know how to do this. please help me im executing shell command in php like this exec('du -s ' . $homepath . escapeshellcmd($username), $return); Code (markup): this output something like this 25632508 /home/user1 Code (markup): so i want to assign only 25632508 to a variable like $usage i dont need /home/user1 part. How can i do it? Thank you.
hmmm.. Odd. Works for me, the echo delivers the first part of the $return Lets try this: $the_txt = exec('du -s ' . $homepath . escapeshellcmd($username), $return); $parts = explode(' ',$the_txt); $usage = $parts[0]; Again.. just a quick attempt, not tested.
ya now it works!!! Thanks mate. One small question if out put is like 25G /home/user1 [lot of spaces between 25G and /home/user1 ] is there any way to assign this ?
Glad that worked out for you! For the lots of spaces... I suppose you could spit it at the '/' -- > altho you will get more parts, its still the first part you want, so that should also work for you. D