-1

I am trying to run an sh script using execv. I have an array "path" which contains all the folders to search in. How can I use the execv command, or any of the other exec libraries to search all directories in the path array to see if the .sh file is in any one of them?

Wragnam
  • 19
  • 2
  • You could loop over all the paths, and then see if the script file exists in the current path in the loop. It's easily done with the [`access`](https://man7.org/linux/man-pages/man2/access.2.html) or [`stat`](https://man7.org/linux/man-pages/man2/stat.2.html) funcitons. – Some programmer dude Aug 27 '23 at 16:32
  • If you want to execute only the first script, not all of them, then just call the `exec` function inside the loop? It it returns then the script wasn't found and you continue the loop. – Some programmer dude Aug 27 '23 at 16:33

0 Answers0