Toolboxcategory cloud |
ViewsPersonal toolsAnswering CLI Prompts ProgramaticallyFrom Seapine LabsSome of the Surround SCM CLI commands prompt the user with an "are you sure [Y/N]:?" question. This presents a problem for users who want to automatically run these commands in a script environment and the commands should not need user interaction (i.e., a user click the "Y" or "N" key when prompted).
[edit] SolutionsSome commands offer a way to not prompt the user. For example, the rm command has a -q option, and when used, it does not prompt the user. However, other commands that do not have this option. Until the option to not prompt the user is added to these commands, the user will have to resort to the scripting language used to automatically answer this question. [edit] DOS exampleIn DOS, you can pipe the answer into the command that you run. For example, I want to delete a branch and do not want to be prompted. If I run the following command:
I get this prompt:
If I run the rb command as a batch file, the question is not answered and the branch is not removed. To solve this problem with DOS commands, pipe the answer to the command. The general syntax is:
In the rb command example, if I change the command in the batch file to look like this:
The command runs, answers the question, and the 'granny' branch is destroyed (because I passed the -d option). [edit] Other ExamplesI work in a Windows environment and could not test if there is a similar option in non-Windows scripting languages, like a shell language for a Unix system. However, I am sure that other scripting languages include a way to pipe the answer to a prompt. [edit] ConclusionPiping the answer to a Surround SCM CLI command prompt allows users to automatically run commands in a script environment, without requiring user interaction.
|
|


