Reputation: 2145
I Just wanna to list all files and subdirectories and store this list in file ... in MS-DOS, Linux and MAC OS, the command line -- .ls( or .dir) >> files.txt -- would give me what I want ... But, how to make a php script run it ?
if I use (on php)
exec ('ls >> files.txt');
I will get a error like this: Warning: Unexpected character in input: '' (ASCII=28) state=0 in /Applications/XAMPP/xamppfiles/htdocs/DjUtilities/makeLabels.php on line 29
...
please, any idea ???
The use of this will be to set labels with the musics in a cd, here, divided by directories... I wanna to get any cd's (subdirectories) and list the files (the tracks) to make a label with the track list....
So, The initial idea was to create a file with these data and then, process the data to make the labels... any better way to do that will be very welcome !!
Upvotes: 0
Views: 721
Reputation: 3008
It's not up to your 'exec(...)' code. Same code runs well in my environment.
<?php
exec('ls >> filelist.txt');
?>
And It's result.
$ cat filelist.txt
a.html
a.out
...(omitted)
So, It looks like your php file may has some weird syntax/characters on line 29. ( like wrong usage of backslashes )
Upvotes: 0
Reputation: 26
You can use 'opendir' and 'readdir' to do that, both native php commands...
Upvotes: 1