Making system calls in C++
First, maybe system calls is a wrong word to describe what I am talking about.
While inside a C++ program (or for that matter, even C will be fine) I want to call `ls > FileListing` and then read the FileListing file through the program . Can it be done? Basically, I have a lot of directories, and I want to parse all the files in those directories, and then do some indexing of the files. Does anyone think using a csh would help? If so, in what way? I was wondering if the name is "c" shell, it must have some benefits to C programmers, right? Thanks a lot Regards Hari |
Check out "man 3 system" or "man 3 exec" for how to call a shell command from C/C++
However, you can do this directly from C/C++ using the "glob" library call, given "*" as an argument to return all files in a directory. From "man 3 glob": Code:
One example of use is the following code, which simulates typing ls -l *.c ../*.c in the shell. Quote:
|
man 3 exec
Was it helpful? *** UPDATE *** Sorry, bulliver was faster than me. |
system was what I was looking for. Thanks a lot.
And by the way, man 3 exec outputs no manual entry for section 3 of exec. But system works fine. Thanks a lot ! Regards hari |
If you type "man 3 exec" on Fedora Core 3 you will see this. I think you get the same output on Slackware 10.1, but I'm not 100% about this. But if system solved your problem, that's fine. :)
|
All times are GMT -5. The time now is 08:29 AM. |