Command Line - Advanced Configurations

Table of Contents

Save As Script

Use Save As Script to save CommCell operations as scripts that can be run from the command line or incorporate it into other scripts. The Save as Script option generates two files on the selected client computer:

Batch or Shell File

The .bat (Windows) and .sh (UNIX) files contain the following commands:

  • qlogin - to log on to the session
  • qoperation execute - to execute the XML file

    Important: Edit the .bat file to include the complete path to your XML file if either of the following apply:

    • The XML file is not located in the software_installation_directory/Base folder
    • You schedule your .bat file as a task in the Windows Task Scheduler
  • qlogout - to logout from the session

The batch file can be executed in two modes:

  • Asynchronous, where the operation is submitted to the CommServe and the return control is given to the calling program or script.
  • Synchronous, where the command line operation exits only after the operation is complete.

XML File

The .xml file contains the options selected from the CommCell Console. This .xml file is the input for the qoperation execute command defined in the batch file. When running the batch file in the command prompt, you can change the XML parameters. These parameters are passed into the generated XML file when the batch file runs. Use the following format:

myscript.bat -parameter value

The .xml file can be used from the command line without the batch file. Use the qoperation execute command and pass in the .xml file as an argument file. Use the following format:

qoperation execute -af backup_template.xml

Save As Script Considerations

  • The script can be run on the CommServe or on any other client computer. If you move the script, you must move both the script and input files to the client computer from which the script will be executed.
  • A script generated by the Save As Script option is supported when the CommServe version is same as the client version. You can not generate scripts when the CommServe has a higher version than the client.
  • Certain characters (for example, the left bracket [ and number sign #) in front of an object name (for example, #csmacs as the subclient name) may cause the script to not work correctly when it is run from the command line. If your script does not work from the command line, check it for these characters. Remove the characters, and then rerun your script.
  • You can save the job options as a script in a local folder on a client machine by entering user credentials and providing the destination path to the client machine.

Save As Script Example

Use the following steps to save the data aging operation as a script:

  1. From the CommCell Browser, right-click the <CommServe> node, point to All Tasks and then click Data Aging.
  2. From the Data Aging Options dialog box, select the data aging options.
  3. Click Save As Script to open the Save As Script dialog box.
  4. In the Client box, select the client computer where the script will be saved.
  5. In the File Path box, enter the location where the script will be saved.

    Alternatively, you can click Browse and navigate to the location.

  6. Add the file name and extension to the location. For example, "C:\scripts\myscript.bat" for Windows or "/usr/scripts/myscript.sh" for UNIX.

    If .xml and .bat/.sh files with the same name already exist, they cannot be overwritten unless the bAllowSaveAsScriptFileOverWrite additional setting is used. For information on adding bAllowSaveAsScriptFileOverWrite, see Enabling File Overwrite.

  7. Click OK.

Restricting Save As Script Operations for Non-Administrators

By default, the Save as Script option is available for all CommCell users. Use the following steps to restrict the usage of this option for all users, except administrators:

  1. From the CommCell Browser, right-click the <CommServe> node and then click Properties.
  2. In the CommCell Properties dialog box, click the Additional Settings tab.
  3. Click Add.
  4. In the Name box, type bAllowSaveAsScriptForAdminOnly. The Category and Type details automatically populate.

    Alternatively, you can click Lookup and search for the global parameter using the Find box.

  5. Select true from the Value list.
  6. Click OK to save the global parameter configuration.
  7. Click OK.

Enabling File Overwrite

During a Save a Script operation, XML and batch files are created on the client. By default, these files cannot be overwritten if they already exist. Use the following steps to allow file overwrite when these files are present:

  1. From the CommCell Browser, right-click the <CommServe> node and then click Properties.
  2. In the CommCell Properties dialog box, click the Additional Settings tab.
  3. Click Add.
  4. In the Name box, type bAllowSaveAsScriptFileOverWrite. The Category and Type details automatically populate.

    Alternatively, you can click Lookup and search for the global parameter using the Find box.

  5. Select true from the Value list.
  6. Click OK to save the global parameter configuration.
  7. Click OK.

Modifying Save As Script (Batch File) Generation

You can use this additional setting to modify batch scripts, which trigger immediate jobs, to wait (and not terminate) till the operation is complete.

  1. From the CommCell Browser, right-click the <CommServe> node and then click Properties.
  2. In the CommCell Properties dialog box, click the Additional Settings tab.
  3. Click Add.
  4. In the Name box, type saveAsScriptWaitForJobComplete.
  5. In the Category box, select EventManager.
  6. In the Type box, select Integer.
  7. Select value from the Value list.
    • 0 - retains the existing behavior in version 10.0.
    • 1 - modifies the batch script generation to wait for job completion.
  8. Click OK.

Forcing Users to Enter Credentials to Run a Saved Script

You can force users to log in when they run a saved script.

When this additional setting is enabled, the batch file that is generated with the Save as Script button does not contain the user's authentication information. A user must enter their credentials when they run the batch file.

Procedure

  1. From the CommCell Browser, right-click the CommServe node and then click Properties.

    The CommCell Properties dialog box appears.

  2. On the Additional Settings tab, click Add.

    The Add Additional Settings dialog box appears.

  3. In the Name box, type SaveAsScriptForceUserLogin.
  4. In the Category box, select CommservDB.GxGlobalParam.
  5. In the Type box, select String.
  6. In the Value box, type 1.
  7. Click OK to close the Add Additional Settings dialog box.
  8. Click OK to close the CommServe Properties dialog box.

Configuring QLogin Command for Local Administrators to Access Without Credentials

You can allow the local administrators from a client computer to run the qlogin command without providing a user name or password. This is done by specifying the -localadmin option for the qlogin command. To enable this option, the nQSDK_ALLOW_LOCAL_ADMIN additional setting must be set in the CommServe computer.

Use the following steps to enable the -localadmin option for the qlogin command:

  1. From the CommCell Browser, right-click the <CommServe> node and then click Properties.
  2. On the CommCell Properties dialog box, click the Additional Settings tab and then click Add.
  3. In the Name box, type nQSDK_ALLOW_LOCAL_ADMIN. The Category and Type details will be automatically populated.

    Alternatively, you can click Lookup and search for the additional setting using the Find box.

  4. In the Value box, type 1.
  5. Click OK to save the additional setting configuration.
  6. Click OK.