I have Write a Bourne shell script that accepts a command as an argument, runs the command and outputs a message which tells the user whether the command was successful or not. For example :
>program cd
command cd successful
>program ls gfdgsfgds
command ls gfdgsfgds not successful
My problem is that I don't know how to get the error codes after the argument has run. Also I tried to use $@ to get the whitespace in the arguments but that didn't work. Any help would be appreciated because I have to do this for an assignment that I've been working on for a couple of days.
>program cd
command cd successful
>program ls gfdgsfgds
command ls gfdgsfgds not successful
My problem is that I don't know how to get the error codes after the argument has run. Also I tried to use $@ to get the whitespace in the arguments but that didn't work. Any help would be appreciated because I have to do this for an assignment that I've been working on for a couple of days.