I want to call/execute a bash from a C program including any number of arguments passed on the command line for the script.
I found a related post How to pass command line arguments from C program to the bash script? but my case is the number of arguments pass to the command line may vary, it's not fixed number. So the C program has to collect any number of command line arguments and pass the same to the bash script to execute.
Is this possible?.
To give you a clear idea, when I run my test bash script, I get the output as expected.
# ./bashex.sh
No arguments passed
# ./bashex.sh hello world
Arguments passed are #1 = hello
Arguments passed are #2 = world
# ./bashex.sh hello world Hi
Arguments passed are #1 = hello
Arguments passed are #2 = world
Arguments passed are #3 = Hi
What I do not know is how to execute this script like this including the command line arguments from a C program