0

Lets say I have a variable storing the name of a compiled C++ program.
executable="myprog.out"

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

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

#!/bin/bash
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,
progArgs="arg1"

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

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

2 Comments

Didn't know you could do the the -- for options. Thank you!!
@syntaxerror Whether you use -- or - depends on the program, this was just an example.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.