| --- |
| title: Creating and Running gfsh Command Scripts |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| gfsh offers several ways to run commands in a scripting environment. |
| |
| ## <a id="concept_9B2F7550F16C4717831AD40A56922259__section_037953D46A644471910B295001E5CE6B" class="no-quick-link"></a>Running gfsh Scripts |
| |
| You can create and run scripts that contain gfsh commands that you wish to execute. To execute the script, use the gfsh [run](command-pages/run.html) command. For example: |
| |
| ``` pre |
| gfsh run --file=mycommands.gfsh |
| ``` |
| |
| **Note:** |
| When you run a gfsh script, interactive parameters are ignored. You can also set the script to run in quiet mode to prevent output and instruct the script to skip any errors it encounters. |
| |
| Your command history file can be helpful when you write a gfsh script. A history of commands that have been executed successfully is logged in the `.gfsh.history` file in the home directory of the user running gfsh. You can also export a history file with the `history --file=your_file_name` command. |
| |
| When a user runs `start server` or `start locator` from gfsh without specifying the member name, gfsh will automatically pick a random member name. This is useful for automation. |