syntax error syntax error - 1 year ago 73
Bash Question

Passing command line arguments in to a bash script command

Lets say I have a variable storing the name of a compiled C++ program.


My script
needs to create a transcript of the C++ program and exit it (without the user having to type
to exit the bash

So far I've achieved this by doing by calling the bash
command inside
script like so,

script -q -c $executable transcript

This method works provided that the C++ program doesn't take command line arguments. If I have a variable holding the command line arguments needed for the program as,


How do I call the script command and have it enter the command line arguments for

Answer Source

The -c option actually takes a shell command as its argument, so you can pass arguments like that:

script -q -c "$executable --opt1 --opt2 -f test" transcript
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download