That works.  Thank you.
Just out of curiosity, from a bash script the following works as expected:
/usr/sbin/vmadm list | /usr/bin/grep myzonealias | /usr/bin/cut -d" " -f1
The following does not work:/usr/sbin/vmadm create -f /opt/json_to_create_vm |  
/usr/bin/cut -d" " -f7
I can grep and cut output from “vmadm list” but neither cut or grep works on 
“vmadm create -f”.Is the issue that “vmadm create -f” creates additional 
processes and writes text to the screen that grep and cut process don’t have 
access to?

    On Friday, February 2, 2018, 1:46:22 PM EST, Jonathan Perkin 
<> wrote:  
 * On 2018-02-02 at 18:24 GMT, George Linn via smartos-discuss wrote:

> I  am trying to figure out how to script some vmadm commands in a bash 
> script. For a basic scenario, the bash script calls vmadm to create a VM and 
> that works fine.  However, I am trying to capture the UUID of the newly 
> created VM.
> I receive the following message on the screen:
> "Successfully created VM 0999429a-6b52-edfd-f0b7-997ca26df1fc"
> Can someone provide an example of how bash can call "vmadm create -f" and 
> record the UUID if the VM is successfully created?
 Rather than parsing the output which shouldn't be considered stable,
 you might want to try the approach of performing a lookup after the
 zone has been created based on the alias you used.
 So, for example, after creating a zone with the 'myzonealias' alias
 (catchy I know!):
   $ vmadm create <<-EOF
   >  ..
   >  "alias": "myzonealias",
   >  ..
   > EOF
 You can use 'vmadm lookup' to retrive the UUID:
   $ myzoneuuid=$(vmadm lookup -1 alias=myzonealias)
 As long as you don't have duplicate aliases (which would probably be a
 bad idea in the first place anyway), this should work fine.
 Jonathan Perkin  -  Joyent, Inc.  -

RSS Feed:
Modify Your Subscription:
Powered by Listbox:

Reply via email to