how to execute windows cmd 'dir > foo.txt' from php -


i'm noobie in php programming. need dump txt files inside directory, stored locally on computer. win cmd dir /b > foo.txt purpose. how can execute command through php? have tried

<?php echo exec("list.bat"); ?> 

.bat file stored on server (hosted on altervista) , contains

cd c:\foo dir /b > files.txt 

but nothing happens. maybe scandir() might used purpose?

@cristik: glob() lists server-side directory contents. there way on client-side? can through php or shall use jscript?

you'd better want use glob() function list directory contents, it's more easier use, doesn't involve system calls, , (the best) it's cross-platform.