Question: task6 Write a bash script accepting three arguments: (stdout file), (stderr file), and (cwd), followed by an arbitrary number of other ar- guments specifying a
task6 Write a bash script accepting three arguments: (stdout file), (stderr file), and (cwd), followed by an arbitrary number of other ar- guments specifying a subcommand and its arguments. The script will run the specified subcommand with all the specified arguments, redirecting the subcommand's stdout to (stdout file) and the subcommand's stderr to stderr file), and setting the subcommand's current working directory to (cwd) For instance, if the script is invoked in the following way: /script.sh /tmp/stdout /tmp/stderr /bin ls -1 -a the command 1s will be run with the arguments -1 and -a. When run, ls's current working directory must be /bin, the stdout output must be saved in (stdout file), and the stderr output must be saved in (stderr file) The script must not change its own current working directory. The script should print to stdout the erit code of the executed subcommand. Nothing else should be print to stdout or stderr To refer to all the arguments specified by the user after the argument cud), I suggest using the bash array variable "$Q: (n))" (substituting (n) with a proper number). I suggest using a subshell not to change the script (cwd) https://en.wikipedia.org/wiki/Unix_time https://www.tldp.org/LDP/abs/html/subshells.html
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
