Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
ddsdmf Absent Member.
Absent Member.

run command scripts from command script

Is it possable to run one command script that can run other command scripts?




5 Replies
Established Member.. mherculea
Established Member..

Re: run command scripts from command script



You can crate a script that connects to NA proxy and runs the following api command.


  run command script

Run an existing command script against a device or group of devices.


run command script [-ip <IP address>] [-host <Hostname>] [-fqdn <Fully Qualified Domain Name>] [-deviceid <Device ID>] [-group <Groupname>] -name <Script Name> [-variables <Variable List>] [-linebyline] [-start <Task start date>] [-rep <Task repeat period>] [-sync] [-nowait] [-comment <Snapshop comment>] [-presnapshot <true or false>] [-postsnapshot <true, false or task>] [-priority <Task priority>]


Runs an existing command script, specified by name, against a device or group of devices. The proper variant of the script will be applied to each device. If no variant of the script supports a given device, that device will be skipped. The script is run as a system task.

  • -ip - a.b.c.d where 0 <= a,b,c,d <= 255. You may optionally prefix the IP with SITE: where SITE is the name of the Site the device is in.
  • -host - A valid hostname
  • -fqdn - A valid Fully Qualified Domain Name
  • -deviceid - A device ID
  • -group - A valid group name. Either a device or a group must be specified, but not both (exactly one of -ip, -hostname, -fqdn or -group must be specified).
  • -name - Name of the command script to run
  • -variables - A list of variables to be replaced in the script - provided as a list of name=value pairs, separated by commas. Values can be surrounded in single-quotes ('). Within a quoted value, a single-quote can be embedded with two single-quote characters. Example: "variable1=value1,varable2='this is ''value 2'''"
  • -linebyline - Indicates that line by line deployment is preferred, rather than file-based deployment
  • -start - YYYY:MM:DD:HH:mm. The first date on which the task will run.
  • -rep - (#min | #:# | #days | #weeks | #months) where # is a positive integer. #:# is hours:minutes--the two integers do not have to be the same. Do not use this option with -sync.
  • -sync - Indicates the command should return only after the snapshot retrieval task is complete. Do not use this option with -rep or -start.
  • -nowait - Indicates that the task should not wait if there is another task currently running against the same device.
  • -comment - An optional comment about the snapshot.
  • -presnapshot - If false, this indicates that the snapshot that runs before the script should be skipped.
  • -postsnapshot - If false, this indicates that the snapshot that runs after the script should be skipped. If "task", this indicates that snapshot after the script should run as a separate task.
  • -priority - Task priority value (1, 2, 3, 4 or 5). Invalid priority will be changed to an appropriate value automatically.

Return Type



  • run command script -ip -name "Extended Ping" -variables "Target_IP=" -start 2004:02:29:23:59 -rep 2days -comment "running extended ping"
  • run command script -ip -name "Extended Ping" -variables "Target_IP=" -start 2004:02:29:23:59 -rep 2days -comment "running extended ping" -priority 3
  • run command script -group mygroup -name "Set Interface Description" -variables "interface=Ethernet1,description='provider ''MCI'',link id T207'" -linebyline -sync

Best regards,

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

Absent Member.. Chris-Powers Absent Member..
Absent Member..

Re: run command scripts from command script

Just another quick note - there's another option that I wanted to mention - may be useful at some point for you.

There's an option (Task / New Multi-Task Project) where you can do a task that will run multiple command scripts.

Nothing wrong with the API option - I've used it too, just wanted to give you options.

If you tweak NA a bit, you can do some interesting things here so failures are excluded.

Hope this helps,
Bobin Thomas Regular Contributor.
Regular Contributor.

Re: run command scripts from command script


how can I write a advanced script to run on NA proxy ?

For example need a script to execute  above command "run script <>" on NA proxy.

So  in GUI , I go to Devices > Device Tools > Command Scripts > click "New Command Script".

In the Script box, how I have to mention to run this command ?

Also while runing this command script as a task,  how can i ask task to run the script on NA proxy in "Applies to" field, I am not able to select NA proxy in this field.


Please help

Chris_Powers Acclaimed Contributor.
Acclaimed Contributor.

Re: run command scripts from command script

OK, in the script box you put in your script commands.  

You don't tell it to run in the proxy - that's something you can do from the proxy if you needed to.  

If you're not used to using NA Proxy, connect to it and then issue the basic command and a ?

run script ? 

You'll get some help info.  

Or just issue ? for a list of available commands

The applies to is the group , list, of devices you want to runt this script on.  Not related to Proxy. 

The proxy is just a command line interface to NA.  Maybe you're accessing NA via some other application, so you can't run the script thru the web UI.  

But if you're in the Web UI, you can just run the script there.  

Hope this helps,

Micro Focus Expert
Micro Focus Expert

Re: run command scripts from command script

Hi @ddsdmf,

I don't know if this is what you are looking for but here it is:

1. create a new run command script

2. paste this:

use Getopt::Long;
use Opsware::NAS::Connect;

my($host, $port, $user, $pass) = ('localhost','$tc_proxy_telnet_port$','$tc_user_username$','$tc_user_password$');
my @output;

my $con = Opsware::NAS::Connect->new(-user => $user, -pass => $pass, -host => $host, -port => $port);

print "Connecting to NA\n";


print "Running Script\n";
@output = $con->cmd("run command script -name \"$my_script$\" -group \"$my_group$\" ");
print join("\n", @output);

@output = $con->cmd("quit");
print join("\n", @output);

@output = $con->disconnect();

undef $con;

3. save

4. you will have to go to Device toolls > Command scripts, click on run and you will see that below you have the option to add the variables for script name ► my_script and group ► my_group.

it sometimes says that the script failed, but if you see this message:

Connecting to NA
Running Script
200 OK: Generic Succeeded
Deploy Change Plan task 16521 queued.

it meas that it worked!!.



Pedro A. Batista
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the THUMB at the bottom left of the post and show your appreciation.
Tags (2)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.