Reputation: 21
I've been successful in writing a C program that copies files from one directory to another and I'm trying to write one that copies directories and sub-directories to another directory.
I've equally been able to write a shell script that copies directories and sub-directories from one location to another.
So, I wish to ask if it is possible to include a shell script into a C program so I won't have to spend time writing another C program to copy directories and sub-directories.
Upvotes: 0
Views: 273
Reputation: 551
Yes its definately possible to call shell scripts or other scripts/executables from C using system(..)
function call. Check system(3).
For the given task of copying directories and subdirectories you can easily code it in C using opendir()
, readdir()
, and other API's.
Check Copy directory recursively in pure C on Linux/UNIX for more details
Upvotes: 2